Ensure that messages to initiate calls are marked urgent=true
This commit is contained in:
		
					parent
					
						
							
								50a2ddf4b2
							
						
					
				
			
			
				commit
				
					
						70cd073a72
					
				
			
		
					 2 changed files with 18 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -6,7 +6,6 @@ import { ipcRenderer } from 'electron';
 | 
			
		|||
import type {
 | 
			
		||||
  AudioDevice,
 | 
			
		||||
  CallId,
 | 
			
		||||
  CallMessageUrgency,
 | 
			
		||||
  DeviceId,
 | 
			
		||||
  PeekInfo,
 | 
			
		||||
  UserId,
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +17,7 @@ import {
 | 
			
		|||
  BusyMessage,
 | 
			
		||||
  Call,
 | 
			
		||||
  CallingMessage,
 | 
			
		||||
  CallMessageUrgency,
 | 
			
		||||
  CallLogLevel,
 | 
			
		||||
  CallState,
 | 
			
		||||
  CanvasVideoRenderer,
 | 
			
		||||
| 
						 | 
				
			
			@ -1146,6 +1146,7 @@ export class CallingClass {
 | 
			
		|||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Used specifically to send updates about in-progress group calls, nothing else
 | 
			
		||||
  private async sendGroupCallUpdateMessage(
 | 
			
		||||
    conversationId: string,
 | 
			
		||||
    eraId: string
 | 
			
		||||
| 
						 | 
				
			
			@ -1188,7 +1189,7 @@ export class CallingClass {
 | 
			
		|||
            sendOptions,
 | 
			
		||||
            sendTarget: conversation.toSenderKeyTarget(),
 | 
			
		||||
            sendType: 'callingMessage',
 | 
			
		||||
            urgent: false,
 | 
			
		||||
            urgent: true,
 | 
			
		||||
          })
 | 
			
		||||
        ),
 | 
			
		||||
      sendType: 'callingMessage',
 | 
			
		||||
| 
						 | 
				
			
			@ -1822,6 +1823,7 @@ export class CallingClass {
 | 
			
		|||
    return this.handleOutgoingSignaling(userId, message, urgency);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Used to send a variety of group call messages, including the initial call message
 | 
			
		||||
  private async handleSendCallMessageToGroup(
 | 
			
		||||
    groupIdBytes: Buffer,
 | 
			
		||||
    data: Buffer,
 | 
			
		||||
| 
						 | 
				
			
			@ -1845,6 +1847,10 @@ export class CallingClass {
 | 
			
		|||
      urgency
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // If this message isn't droppable, we'll wake up recipient devices. The important one
 | 
			
		||||
    //   is the first message to start the call.
 | 
			
		||||
    const urgent = urgency === CallMessageUrgency.HandleImmediately;
 | 
			
		||||
 | 
			
		||||
    // We "fire and forget" because sending this message is non-essential.
 | 
			
		||||
    // We also don't sync this message.
 | 
			
		||||
    const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
 | 
			
		||||
| 
						 | 
				
			
			@ -1860,7 +1866,7 @@ export class CallingClass {
 | 
			
		|||
          sendTarget: conversation.toSenderKeyTarget(),
 | 
			
		||||
          sendType: 'callingMessage',
 | 
			
		||||
          timestamp,
 | 
			
		||||
          urgent: false,
 | 
			
		||||
          urgent,
 | 
			
		||||
        }),
 | 
			
		||||
        { messageIds: [], sendType: 'callingMessage' }
 | 
			
		||||
      )
 | 
			
		||||
| 
						 | 
				
			
			@ -1966,6 +1972,7 @@ export class CallingClass {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Used for all 1:1 call messages, including the initial message to start the call
 | 
			
		||||
  private async handleOutgoingSignaling(
 | 
			
		||||
    remoteUserId: UserId,
 | 
			
		||||
    message: CallingMessage,
 | 
			
		||||
| 
						 | 
				
			
			@ -1981,12 +1988,18 @@ export class CallingClass {
 | 
			
		|||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // We want 1:1 call initiate messages to wake up recipient devices, but not others
 | 
			
		||||
    const urgent =
 | 
			
		||||
      urgency === CallMessageUrgency.HandleImmediately ||
 | 
			
		||||
      Boolean(message.offer);
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      assertDev(isAciString(remoteUserId), 'remoteUserId is not a aci');
 | 
			
		||||
      const result = await handleMessageSend(
 | 
			
		||||
        window.textsecure.messaging.sendCallingMessage(
 | 
			
		||||
          remoteUserId,
 | 
			
		||||
          callingMessageToProto(message, urgency),
 | 
			
		||||
          urgent,
 | 
			
		||||
          sendOptions
 | 
			
		||||
        ),
 | 
			
		||||
        { messageIds: [], sendType: 'callingMessage' }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1702,6 +1702,7 @@ export default class MessageSender {
 | 
			
		|||
  async sendCallingMessage(
 | 
			
		||||
    serviceId: ServiceIdString,
 | 
			
		||||
    callingMessage: Readonly<Proto.ICallingMessage>,
 | 
			
		||||
    urgent: boolean,
 | 
			
		||||
    options?: Readonly<SendOptionsType>
 | 
			
		||||
  ): Promise<CallbackResultType> {
 | 
			
		||||
    const recipients = [serviceId];
 | 
			
		||||
| 
						 | 
				
			
			@ -1727,7 +1728,7 @@ export default class MessageSender {
 | 
			
		|||
      contentHint: ContentHint.DEFAULT,
 | 
			
		||||
      groupId: undefined,
 | 
			
		||||
      options,
 | 
			
		||||
      urgent: true,
 | 
			
		||||
      urgent,
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue