Send viewed receipt for view-once opens

This commit is contained in:
yash-signal
2026-02-18 12:28:16 -06:00
committed by GitHub
parent 6aca6a278a
commit c8619bc42b
4 changed files with 65 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ import {
type Device,
type Group,
PrimaryDevice,
type Proto,
Proto,
StorageState,
} from '@signalapp/mock-server';
import { assert } from 'chai';
@@ -30,6 +30,30 @@ export function bufferToUuid(buffer: Buffer): string {
].join('-');
}
function isProfileKeyUpdate(flags: number | null | undefined): boolean {
if (flags == null) {
return false;
}
// eslint-disable-next-line no-bitwise
return (flags & Proto.DataMessage.Flags.PROFILE_KEY_UPDATE) !== 0;
}
export async function waitForNonProfileKeyUpdateMessage(
device: PrimaryDevice,
{ maxAttempts = 5 }: { maxAttempts?: number } = {}
): Promise<Awaited<ReturnType<PrimaryDevice['waitForMessage']>>> {
for (let i = 0; i < maxAttempts; i += 1) {
// eslint-disable-next-line no-await-in-loop
const message = await device.waitForMessage();
if (isProfileKeyUpdate(message.dataMessage.flags)) {
debug('Skipping profile key update');
continue;
}
return message;
}
throw new Error(`No message with body after ${maxAttempts} attempts`);
}
export async function typeIntoInput(
input: Locator,
additionalText: string,