mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-18 15:45:39 +01:00
Send viewed receipt for view-once opens
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user