Call link call history
This commit is contained in:
parent
ed940f6f83
commit
00d6379bae
29 changed files with 1124 additions and 204 deletions
|
@ -10,7 +10,16 @@ import {
|
|||
} from './zkgroup';
|
||||
import { getCheckedCallLinkAuthCredentialsForToday } from '../services/groupCredentialFetcher';
|
||||
import * as durations from './durations';
|
||||
import type { CallLinkConversationType, CallLinkType } from '../types/CallLink';
|
||||
import * as Bytes from '../Bytes';
|
||||
import type {
|
||||
CallLinkConversationType,
|
||||
CallLinkType,
|
||||
CallLinkRecord,
|
||||
} from '../types/CallLink';
|
||||
import {
|
||||
callLinkRecordSchema,
|
||||
toCallLinkRestrictions,
|
||||
} from '../types/CallLink';
|
||||
import type { LocalizerType } from '../types/Util';
|
||||
|
||||
export function getRoomIdFromRootKey(rootKey: CallLinkRootKey): string {
|
||||
|
@ -71,3 +80,47 @@ export function callLinkToConversation(
|
|||
badges: [],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* DB record conversions
|
||||
*/
|
||||
|
||||
export function callLinkToRecord(callLink: CallLinkType): CallLinkRecord {
|
||||
if (callLink.rootKey == null) {
|
||||
throw new Error('CallLink.callLinkToRecord: rootKey is null');
|
||||
}
|
||||
|
||||
// rootKey has a RingRTC parsing function, adminKey is just bytes
|
||||
const rootKey = callLink.rootKey
|
||||
? CallLinkRootKey.parse(callLink.rootKey).bytes
|
||||
: null;
|
||||
const adminKey = callLink.adminKey
|
||||
? Bytes.fromBase64(callLink.adminKey)
|
||||
: null;
|
||||
return callLinkRecordSchema.parse({
|
||||
roomId: callLink.roomId,
|
||||
rootKey,
|
||||
adminKey,
|
||||
name: callLink.name,
|
||||
restrictions: callLink.restrictions,
|
||||
revoked: callLink.revoked ? 1 : 0,
|
||||
expiration: callLink.expiration,
|
||||
});
|
||||
}
|
||||
|
||||
export function callLinkFromRecord(record: CallLinkRecord): CallLinkType {
|
||||
// root keys in memory are strings for simplicity
|
||||
const rootKey = CallLinkRootKey.fromBytes(
|
||||
record.rootKey as Buffer
|
||||
).toString();
|
||||
const adminKey = record.adminKey ? Bytes.toBase64(record.adminKey) : null;
|
||||
return {
|
||||
roomId: record.roomId,
|
||||
rootKey,
|
||||
adminKey,
|
||||
name: record.name,
|
||||
restrictions: toCallLinkRestrictions(record.restrictions),
|
||||
revoked: record.revoked === 1,
|
||||
expiration: record.expiration,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue