Calling: When calling out, send profileKey to 1:1 recipient
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
a04e0a4616
commit
37fa0b3466
2 changed files with 46 additions and 17 deletions
|
@ -2361,10 +2361,13 @@ export async function startApp(): Promise<void> {
|
||||||
const { data, confirm } = event;
|
const { data, confirm } = event;
|
||||||
|
|
||||||
const messageDescriptor = getMessageDescriptor({
|
const messageDescriptor = getMessageDescriptor({
|
||||||
message: data.message,
|
|
||||||
// 'message' event: for 1:1 converations, the conversation is same as sender
|
// 'message' event: for 1:1 converations, the conversation is same as sender
|
||||||
destination: data.source,
|
destination: data.source,
|
||||||
destinationServiceId: data.sourceAci,
|
destinationServiceId: data.sourceAci,
|
||||||
|
envelopeId: data.envelopeId,
|
||||||
|
message: data.message,
|
||||||
|
source: data.sourceAci ?? data.source,
|
||||||
|
sourceDevice: data.sourceDevice,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { PROFILE_KEY_UPDATE } = Proto.DataMessage.Flags;
|
const { PROFILE_KEY_UPDATE } = Proto.DataMessage.Flags;
|
||||||
|
@ -2706,18 +2709,26 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
// Works with 'sent' and 'message' data sent from MessageReceiver
|
// Works with 'sent' and 'message' data sent from MessageReceiver
|
||||||
const getMessageDescriptor = ({
|
const getMessageDescriptor = ({
|
||||||
message,
|
|
||||||
destination,
|
destination,
|
||||||
destinationServiceId,
|
destinationServiceId,
|
||||||
|
envelopeId,
|
||||||
|
message,
|
||||||
|
source,
|
||||||
|
sourceDevice,
|
||||||
}: {
|
}: {
|
||||||
message: ProcessedDataMessage;
|
|
||||||
destination?: string;
|
destination?: string;
|
||||||
destinationServiceId?: ServiceIdString;
|
destinationServiceId?: ServiceIdString;
|
||||||
|
envelopeId: string;
|
||||||
|
message: ProcessedDataMessage;
|
||||||
|
source: string | undefined;
|
||||||
|
sourceDevice: number | undefined;
|
||||||
}): MessageDescriptor => {
|
}): MessageDescriptor => {
|
||||||
|
const logId = `getMessageDescriptor/${source}.${sourceDevice}-${envelopeId}`;
|
||||||
|
|
||||||
if (message.groupV2) {
|
if (message.groupV2) {
|
||||||
const { id } = message.groupV2;
|
const { id } = message.groupV2;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
throw new Error('getMessageDescriptor: GroupV2 data was missing an id');
|
throw new Error(`${logId}: GroupV2 data was missing an id`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// First we check for an existing GroupV2 group
|
// First we check for an existing GroupV2 group
|
||||||
|
@ -2752,10 +2763,15 @@ export async function startApp(): Promise<void> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const conversation = window.ConversationController.get(
|
const id = destinationServiceId || destination;
|
||||||
destinationServiceId || destination
|
strictAssert(
|
||||||
|
id,
|
||||||
|
`${logId}: We need some sort of destination for the conversation`
|
||||||
|
);
|
||||||
|
const conversation = window.ConversationController.getOrCreate(
|
||||||
|
id,
|
||||||
|
'private'
|
||||||
);
|
);
|
||||||
strictAssert(conversation, 'Destination conversation cannot be created');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: Message.PRIVATE,
|
type: Message.PRIVATE,
|
||||||
|
@ -2797,6 +2813,8 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
const messageDescriptor = getMessageDescriptor({
|
const messageDescriptor = getMessageDescriptor({
|
||||||
...data,
|
...data,
|
||||||
|
source: sourceServiceId,
|
||||||
|
sourceDevice: data.device,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { PROFILE_KEY_UPDATE } = Proto.DataMessage.Flags;
|
const { PROFILE_KEY_UPDATE } = Proto.DataMessage.Flags;
|
||||||
|
|
|
@ -885,50 +885,61 @@ export class CallingClass {
|
||||||
hasLocalAudio: boolean,
|
hasLocalAudio: boolean,
|
||||||
hasLocalVideo: boolean
|
hasLocalVideo: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
log.info('CallingClass.startOutgoingDirectCall()');
|
const logId = 'CallingClass.startOutgoingDirectCall';
|
||||||
|
log.info(logId);
|
||||||
|
|
||||||
if (!this.reduxInterface) {
|
if (!this.reduxInterface) {
|
||||||
throw new Error('Redux actions not available');
|
throw new Error(`${logId}: Redux actions not available`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const conversation = window.ConversationController.get(conversationId);
|
const conversation = window.ConversationController.get(conversationId);
|
||||||
if (!conversation) {
|
if (!conversation) {
|
||||||
log.error('Could not find conversation, cannot start call');
|
log.error(`${logId}: Could not find conversation, cannot start call`);
|
||||||
this.stopCallingLobby();
|
this.stopCallingLobby();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteUserId = this.getRemoteUserIdFromConversation(conversation);
|
const remoteUserId = this.getRemoteUserIdFromConversation(conversation);
|
||||||
if (!remoteUserId || !this.localDeviceId) {
|
if (!remoteUserId || !this.localDeviceId) {
|
||||||
log.error('Missing identifier, new call not allowed.');
|
log.error(`${logId}: Missing identifier, new call not allowed.`);
|
||||||
this.stopCallingLobby();
|
this.stopCallingLobby();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const haveMediaPermissions = await this.requestPermissions(hasLocalVideo);
|
const haveMediaPermissions = await this.requestPermissions(hasLocalVideo);
|
||||||
if (!haveMediaPermissions) {
|
if (!haveMediaPermissions) {
|
||||||
log.info('Permissions were denied, new call not allowed.');
|
log.info(`${logId}: Permissions were denied, new call not allowed.`);
|
||||||
this.stopCallingLobby();
|
this.stopCallingLobby();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info('CallingClass.startOutgoingDirectCall(): Getting call settings');
|
log.info(`${logId}: Getting call settings`);
|
||||||
|
|
||||||
// Check state after awaiting to debounce call button.
|
// Check state after awaiting to debounce call button.
|
||||||
if (RingRTC.call && RingRTC.call.state !== CallState.Ended) {
|
if (RingRTC.call && RingRTC.call.state !== CallState.Ended) {
|
||||||
log.info('Call already in progress, new call not allowed.');
|
log.info(`${logId}: Call already in progress, new call not allowed.`);
|
||||||
this.stopCallingLobby();
|
this.stopCallingLobby();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info('CallingClass.startOutgoingDirectCall(): Starting in RingRTC');
|
log.info(`${logId}: Starting in RingRTC`);
|
||||||
|
|
||||||
const call = RingRTC.startOutgoingCall(
|
const call = RingRTC.startOutgoingCall(
|
||||||
remoteUserId,
|
remoteUserId,
|
||||||
hasLocalVideo,
|
hasLocalVideo,
|
||||||
this.localDeviceId
|
this.localDeviceId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Send profile key to conversation recipient since call protos don't include it
|
||||||
|
if (!conversation.get('profileSharing')) {
|
||||||
|
log.info(`${logId}: Setting profileSharing=true`);
|
||||||
|
conversation.set({ profileSharing: true });
|
||||||
|
await DataWriter.updateConversation(conversation.attributes);
|
||||||
|
}
|
||||||
|
log.info(`${logId}: Sending profile key`);
|
||||||
|
await conversationJobQueue.add({
|
||||||
|
conversationId: conversation.id,
|
||||||
|
type: 'ProfileKey',
|
||||||
|
});
|
||||||
|
|
||||||
RingRTC.setOutgoingAudio(call.callId, hasLocalAudio);
|
RingRTC.setOutgoingAudio(call.callId, hasLocalAudio);
|
||||||
RingRTC.setVideoCapturer(call.callId, this.videoCapturer);
|
RingRTC.setVideoCapturer(call.callId, this.videoCapturer);
|
||||||
RingRTC.setVideoRenderer(call.callId, this.videoRenderer);
|
RingRTC.setVideoRenderer(call.callId, this.videoRenderer);
|
||||||
|
|
Loading…
Reference in a new issue