Sync call link call history
This commit is contained in:
parent
ce83195170
commit
2785501f82
26 changed files with 800 additions and 175 deletions
|
@ -9,11 +9,13 @@ import { aciSchema } from './ServiceId';
|
|||
import { bytesToUuid } from '../util/uuidToBytes';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import * as Bytes from '../Bytes';
|
||||
import { UUID_BYTE_SIZE } from './Crypto';
|
||||
|
||||
export enum CallType {
|
||||
Audio = 'Audio',
|
||||
Video = 'Video',
|
||||
Group = 'Group',
|
||||
Adhoc = 'Adhoc',
|
||||
}
|
||||
|
||||
export enum CallDirection {
|
||||
|
@ -45,30 +47,42 @@ export enum RemoteCallEvent {
|
|||
|
||||
export type CallEvent = LocalCallEvent | RemoteCallEvent;
|
||||
|
||||
export enum DirectCallStatus {
|
||||
export enum CallStatusValue {
|
||||
Pending = 'Pending',
|
||||
Accepted = 'Accepted',
|
||||
Missed = 'Missed',
|
||||
Declined = 'Declined',
|
||||
Deleted = 'Deleted',
|
||||
}
|
||||
|
||||
export enum GroupCallStatus {
|
||||
GenericGroupCall = 'GenericGroupCall',
|
||||
OutgoingRing = 'OutgoingRing',
|
||||
Ringing = 'Ringing',
|
||||
Joined = 'Joined',
|
||||
// keep these in sync with direct
|
||||
Accepted = DirectCallStatus.Accepted,
|
||||
Missed = DirectCallStatus.Missed,
|
||||
Declined = DirectCallStatus.Declined,
|
||||
Deleted = DirectCallStatus.Deleted,
|
||||
JoinedAdhoc = 'JoinedAdhoc',
|
||||
}
|
||||
|
||||
export enum DirectCallStatus {
|
||||
Pending = CallStatusValue.Pending,
|
||||
Accepted = CallStatusValue.Accepted,
|
||||
Missed = CallStatusValue.Missed,
|
||||
Declined = CallStatusValue.Declined,
|
||||
Deleted = CallStatusValue.Deleted,
|
||||
}
|
||||
|
||||
export enum GroupCallStatus {
|
||||
GenericGroupCall = CallStatusValue.GenericGroupCall,
|
||||
OutgoingRing = CallStatusValue.OutgoingRing,
|
||||
Ringing = CallStatusValue.Ringing,
|
||||
Joined = CallStatusValue.Joined,
|
||||
Accepted = CallStatusValue.Accepted,
|
||||
Missed = CallStatusValue.Missed,
|
||||
Declined = CallStatusValue.Declined,
|
||||
Deleted = CallStatusValue.Deleted,
|
||||
}
|
||||
|
||||
export enum AdhocCallStatus {
|
||||
Pending = DirectCallStatus.Pending,
|
||||
Joined = GroupCallStatus.Joined,
|
||||
Deleted = DirectCallStatus.Deleted,
|
||||
Pending = CallStatusValue.Pending,
|
||||
Joined = CallStatusValue.JoinedAdhoc,
|
||||
Deleted = CallStatusValue.Deleted,
|
||||
}
|
||||
|
||||
export type CallStatus = DirectCallStatus | GroupCallStatus | AdhocCallStatus;
|
||||
|
@ -177,11 +191,15 @@ export const callHistoryGroupSchema = z.object({
|
|||
}) satisfies z.ZodType<CallHistoryGroup>;
|
||||
|
||||
const peerIdInBytesSchema = z.instanceof(Uint8Array).transform(value => {
|
||||
const uuid = bytesToUuid(value);
|
||||
if (uuid != null) {
|
||||
return uuid;
|
||||
// direct conversationId
|
||||
if (value.byteLength === UUID_BYTE_SIZE) {
|
||||
const uuid = bytesToUuid(value);
|
||||
if (uuid != null) {
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
// assuming groupId
|
||||
|
||||
// groupId or call link roomId
|
||||
return Bytes.toBase64(value);
|
||||
});
|
||||
|
||||
|
|
|
@ -4,6 +4,16 @@ import type { ReadonlyDeep } from 'type-fest';
|
|||
import { z } from 'zod';
|
||||
import type { ConversationType } from '../state/ducks/conversations';
|
||||
|
||||
export enum CallLinkUpdateSyncType {
|
||||
Update = 'Update',
|
||||
Delete = 'Delete',
|
||||
}
|
||||
|
||||
export type CallLinkUpdateData = Readonly<{
|
||||
rootKey: Uint8Array;
|
||||
adminKey: Uint8Array | undefined;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Restrictions
|
||||
*/
|
||||
|
@ -33,10 +43,25 @@ export type CallLinkType = Readonly<{
|
|||
adminKey: string | null;
|
||||
name: string;
|
||||
restrictions: CallLinkRestrictions;
|
||||
// Revocation is not supported currently but still returned by the server
|
||||
revoked: boolean;
|
||||
// Guaranteed from RingRTC readCallLink, but locally may be null immediately after
|
||||
// CallLinkUpdate sync and before readCallLink
|
||||
expiration: number | null;
|
||||
}>;
|
||||
|
||||
export type CallLinkStateType = Pick<
|
||||
CallLinkType,
|
||||
'name' | 'restrictions' | 'revoked' | 'expiration'
|
||||
>;
|
||||
|
||||
export type ReadCallLinkState = Readonly<{
|
||||
name: string;
|
||||
restrictions: CallLinkRestrictions;
|
||||
revoked: boolean;
|
||||
expiration: number;
|
||||
}>;
|
||||
|
||||
// Ephemeral conversation-like type to satisfy components
|
||||
export type CallLinkConversationType = ReadonlyDeep<
|
||||
Omit<ConversationType, 'type'> & {
|
||||
|
@ -65,6 +90,6 @@ export const callLinkRecordSchema = z.object({
|
|||
// state
|
||||
name: z.string(),
|
||||
restrictions: callLinkRestrictionsSchema,
|
||||
expiration: z.number().int(),
|
||||
expiration: z.number().int().nullable(),
|
||||
revoked: z.union([z.literal(1), z.literal(0)]),
|
||||
}) satisfies z.ZodType<CallLinkRecord>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue