signal-desktop/ts/test-both/helpers/fakeCallLink.ts

59 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-04-25 17:09:05 +00:00
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { CallLinkStateType, CallLinkType } from '../../types/CallLink';
import type { CallingConversationType } from '../../types/Calling';
2024-04-25 17:09:05 +00:00
import { CallLinkRestrictions } from '../../types/CallLink';
import { MONTH } from '../../util/durations/constants';
export const FAKE_CALL_LINK: CallLinkType = {
adminKey: null,
expiration: Date.now() + MONTH, // set me
name: 'Fun Link',
restrictions: CallLinkRestrictions.None,
revoked: false,
2024-05-17 23:22:51 +00:00
roomId: 'd517b48dd118bee24068d4938886c8abe192706d84936d52594a9157189d2759',
rootKey: 'dxbb-xfqz-xkgp-nmrx-bpqn-ptkb-spdt-pdgt',
2024-09-04 18:06:06 +00:00
storageID: undefined,
storageVersion: undefined,
storageUnknownFields: undefined,
storageNeedsSync: false,
2024-04-25 17:09:05 +00:00
};
// Please set expiration
export const FAKE_CALL_LINK_WITH_ADMIN_KEY: CallLinkType = {
adminKey: 'xXPI77e6MoVHYREW8iKYmQ==',
expiration: Date.now() + MONTH, // set me
2024-05-17 23:22:51 +00:00
name: 'Admin Link',
2024-04-25 17:09:05 +00:00
restrictions: CallLinkRestrictions.None,
revoked: false,
roomId: 'c097eb04cc278d6bc7ed9fb2ddeac00dc9646ae6ddb38513dad9a8a4fe3c38f4',
rootKey: 'bpmc-mrgn-hntf-mffd-mndd-xbxk-zmgq-qszg',
2024-09-04 18:06:06 +00:00
storageID: undefined,
storageVersion: undefined,
storageUnknownFields: undefined,
storageNeedsSync: false,
2024-04-25 17:09:05 +00:00
};
export function getCallLinkState(callLink: CallLinkType): CallLinkStateType {
const { name, restrictions, expiration, revoked } = callLink;
return { name, restrictions, expiration, revoked };
}
export function getDefaultCallLinkConversation(
callLinkOverrideProps: Partial<CallLinkType> = {}
): CallingConversationType {
const { roomId: id, name: title } = {
...FAKE_CALL_LINK,
...callLinkOverrideProps,
};
return {
id,
type: 'callLink',
isMe: false,
title,
sharedGroupNames: [],
acceptedMessageRequest: true,
badges: [],
};
}