Add ProfileKeyForCall conversation job
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
parent
3aa54a3070
commit
9ba6df8ef2
3 changed files with 13 additions and 5 deletions
|
@ -64,6 +64,7 @@ export const conversationQueueJobEnum = z.enum([
|
||||||
'NormalMessage',
|
'NormalMessage',
|
||||||
'NullMessage',
|
'NullMessage',
|
||||||
'ProfileKey',
|
'ProfileKey',
|
||||||
|
'ProfileKeyForCall',
|
||||||
'Reaction',
|
'Reaction',
|
||||||
'ResendRequest',
|
'ResendRequest',
|
||||||
'SavedProto',
|
'SavedProto',
|
||||||
|
@ -165,7 +166,10 @@ const nullMessageJobDataSchema = z.object({
|
||||||
export type NullMessageJobData = z.infer<typeof nullMessageJobDataSchema>;
|
export type NullMessageJobData = z.infer<typeof nullMessageJobDataSchema>;
|
||||||
|
|
||||||
const profileKeyJobDataSchema = z.object({
|
const profileKeyJobDataSchema = z.object({
|
||||||
type: z.literal(conversationQueueJobEnum.enum.ProfileKey),
|
type: z.union([
|
||||||
|
z.literal(conversationQueueJobEnum.enum.ProfileKey),
|
||||||
|
z.literal(conversationQueueJobEnum.enum.ProfileKeyForCall),
|
||||||
|
]),
|
||||||
conversationId: z.string(),
|
conversationId: z.string(),
|
||||||
// Note: we will use whichever recipients list is up to date when this job runs
|
// Note: we will use whichever recipients list is up to date when this job runs
|
||||||
revision: z.number().optional(),
|
revision: z.number().optional(),
|
||||||
|
@ -297,6 +301,9 @@ function shouldSendShowCaptcha(type: ConversationQueueJobEnum): boolean {
|
||||||
if (type === 'ProfileKey') {
|
if (type === 'ProfileKey') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (type === 'ProfileKeyForCall') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (type === 'Reaction') {
|
if (type === 'Reaction') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -946,6 +953,7 @@ export class ConversationJobQueue extends JobQueue<ConversationQueueJobData> {
|
||||||
await sendNullMessage(conversation, jobBundle, data);
|
await sendNullMessage(conversation, jobBundle, data);
|
||||||
break;
|
break;
|
||||||
case jobSet.ProfileKey:
|
case jobSet.ProfileKey:
|
||||||
|
case jobSet.ProfileKeyForCall:
|
||||||
await sendProfileKey(conversation, jobBundle, data);
|
await sendProfileKey(conversation, jobBundle, data);
|
||||||
break;
|
break;
|
||||||
case jobSet.Reaction:
|
case jobSet.Reaction:
|
||||||
|
@ -1042,7 +1050,7 @@ export class ConversationJobQueue extends JobQueue<ConversationQueueJobData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (untrustedServiceIds.length) {
|
if (untrustedServiceIds.length) {
|
||||||
if (type === jobSet.ProfileKey) {
|
if (type === jobSet.ProfileKey || type === jobSet.ProfileKeyForCall) {
|
||||||
log.warn(
|
log.warn(
|
||||||
`Cancelling profile share, since there were ${untrustedServiceIds.length} untrusted send targets.`
|
`Cancelling profile share, since there were ${untrustedServiceIds.length} untrusted send targets.`
|
||||||
);
|
);
|
||||||
|
|
|
@ -90,7 +90,7 @@ export async function sendProfileKey(
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
`starting profile key share to ${conversation.idForLogging()} with timestamp ${timestamp}`
|
`starting profile key share to ${conversation.idForLogging()} with timestamp ${timestamp} type=${data.type}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const { revision } = data;
|
const { revision } = data;
|
||||||
|
|
|
@ -926,7 +926,7 @@ export class CallingClass {
|
||||||
log.info(`${logId}: Sending profile key`);
|
log.info(`${logId}: Sending profile key`);
|
||||||
await conversationJobQueue.add({
|
await conversationJobQueue.add({
|
||||||
conversationId: conversation.id,
|
conversationId: conversation.id,
|
||||||
type: 'ProfileKey',
|
type: 'ProfileKeyForCall',
|
||||||
});
|
});
|
||||||
|
|
||||||
RingRTC.setOutgoingAudio(call.callId, hasLocalAudio);
|
RingRTC.setOutgoingAudio(call.callId, hasLocalAudio);
|
||||||
|
@ -1544,7 +1544,7 @@ export class CallingClass {
|
||||||
log.info(`${logId}: Sending profile key`);
|
log.info(`${logId}: Sending profile key`);
|
||||||
drop(
|
drop(
|
||||||
conversationJobQueue.add({
|
conversationJobQueue.add({
|
||||||
type: conversationQueueJobEnum.enum.ProfileKey,
|
type: conversationQueueJobEnum.enum.ProfileKeyForCall,
|
||||||
conversationId: conversation.id,
|
conversationId: conversation.id,
|
||||||
isOneTimeSend: true,
|
isOneTimeSend: true,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue