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 {
 | 
					import type {
 | 
				
			||||||
  AudioDevice,
 | 
					  AudioDevice,
 | 
				
			||||||
  CallId,
 | 
					  CallId,
 | 
				
			||||||
  CallMessageUrgency,
 | 
					 | 
				
			||||||
  DeviceId,
 | 
					  DeviceId,
 | 
				
			||||||
  PeekInfo,
 | 
					  PeekInfo,
 | 
				
			||||||
  UserId,
 | 
					  UserId,
 | 
				
			||||||
| 
						 | 
					@ -18,6 +17,7 @@ import {
 | 
				
			||||||
  BusyMessage,
 | 
					  BusyMessage,
 | 
				
			||||||
  Call,
 | 
					  Call,
 | 
				
			||||||
  CallingMessage,
 | 
					  CallingMessage,
 | 
				
			||||||
 | 
					  CallMessageUrgency,
 | 
				
			||||||
  CallLogLevel,
 | 
					  CallLogLevel,
 | 
				
			||||||
  CallState,
 | 
					  CallState,
 | 
				
			||||||
  CanvasVideoRenderer,
 | 
					  CanvasVideoRenderer,
 | 
				
			||||||
| 
						 | 
					@ -1146,6 +1146,7 @@ export class CallingClass {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Used specifically to send updates about in-progress group calls, nothing else
 | 
				
			||||||
  private async sendGroupCallUpdateMessage(
 | 
					  private async sendGroupCallUpdateMessage(
 | 
				
			||||||
    conversationId: string,
 | 
					    conversationId: string,
 | 
				
			||||||
    eraId: string
 | 
					    eraId: string
 | 
				
			||||||
| 
						 | 
					@ -1188,7 +1189,7 @@ export class CallingClass {
 | 
				
			||||||
            sendOptions,
 | 
					            sendOptions,
 | 
				
			||||||
            sendTarget: conversation.toSenderKeyTarget(),
 | 
					            sendTarget: conversation.toSenderKeyTarget(),
 | 
				
			||||||
            sendType: 'callingMessage',
 | 
					            sendType: 'callingMessage',
 | 
				
			||||||
            urgent: false,
 | 
					            urgent: true,
 | 
				
			||||||
          })
 | 
					          })
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
      sendType: 'callingMessage',
 | 
					      sendType: 'callingMessage',
 | 
				
			||||||
| 
						 | 
					@ -1822,6 +1823,7 @@ export class CallingClass {
 | 
				
			||||||
    return this.handleOutgoingSignaling(userId, message, urgency);
 | 
					    return this.handleOutgoingSignaling(userId, message, urgency);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Used to send a variety of group call messages, including the initial call message
 | 
				
			||||||
  private async handleSendCallMessageToGroup(
 | 
					  private async handleSendCallMessageToGroup(
 | 
				
			||||||
    groupIdBytes: Buffer,
 | 
					    groupIdBytes: Buffer,
 | 
				
			||||||
    data: Buffer,
 | 
					    data: Buffer,
 | 
				
			||||||
| 
						 | 
					@ -1845,6 +1847,10 @@ export class CallingClass {
 | 
				
			||||||
      urgency
 | 
					      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 "fire and forget" because sending this message is non-essential.
 | 
				
			||||||
    // We also don't sync this message.
 | 
					    // We also don't sync this message.
 | 
				
			||||||
    const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
 | 
					    const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
 | 
				
			||||||
| 
						 | 
					@ -1860,7 +1866,7 @@ export class CallingClass {
 | 
				
			||||||
          sendTarget: conversation.toSenderKeyTarget(),
 | 
					          sendTarget: conversation.toSenderKeyTarget(),
 | 
				
			||||||
          sendType: 'callingMessage',
 | 
					          sendType: 'callingMessage',
 | 
				
			||||||
          timestamp,
 | 
					          timestamp,
 | 
				
			||||||
          urgent: false,
 | 
					          urgent,
 | 
				
			||||||
        }),
 | 
					        }),
 | 
				
			||||||
        { messageIds: [], sendType: 'callingMessage' }
 | 
					        { 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(
 | 
					  private async handleOutgoingSignaling(
 | 
				
			||||||
    remoteUserId: UserId,
 | 
					    remoteUserId: UserId,
 | 
				
			||||||
    message: CallingMessage,
 | 
					    message: CallingMessage,
 | 
				
			||||||
| 
						 | 
					@ -1981,12 +1988,18 @@ export class CallingClass {
 | 
				
			||||||
      return false;
 | 
					      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 {
 | 
					    try {
 | 
				
			||||||
      assertDev(isAciString(remoteUserId), 'remoteUserId is not a aci');
 | 
					      assertDev(isAciString(remoteUserId), 'remoteUserId is not a aci');
 | 
				
			||||||
      const result = await handleMessageSend(
 | 
					      const result = await handleMessageSend(
 | 
				
			||||||
        window.textsecure.messaging.sendCallingMessage(
 | 
					        window.textsecure.messaging.sendCallingMessage(
 | 
				
			||||||
          remoteUserId,
 | 
					          remoteUserId,
 | 
				
			||||||
          callingMessageToProto(message, urgency),
 | 
					          callingMessageToProto(message, urgency),
 | 
				
			||||||
 | 
					          urgent,
 | 
				
			||||||
          sendOptions
 | 
					          sendOptions
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        { messageIds: [], sendType: 'callingMessage' }
 | 
					        { messageIds: [], sendType: 'callingMessage' }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1702,6 +1702,7 @@ export default class MessageSender {
 | 
				
			||||||
  async sendCallingMessage(
 | 
					  async sendCallingMessage(
 | 
				
			||||||
    serviceId: ServiceIdString,
 | 
					    serviceId: ServiceIdString,
 | 
				
			||||||
    callingMessage: Readonly<Proto.ICallingMessage>,
 | 
					    callingMessage: Readonly<Proto.ICallingMessage>,
 | 
				
			||||||
 | 
					    urgent: boolean,
 | 
				
			||||||
    options?: Readonly<SendOptionsType>
 | 
					    options?: Readonly<SendOptionsType>
 | 
				
			||||||
  ): Promise<CallbackResultType> {
 | 
					  ): Promise<CallbackResultType> {
 | 
				
			||||||
    const recipients = [serviceId];
 | 
					    const recipients = [serviceId];
 | 
				
			||||||
| 
						 | 
					@ -1727,7 +1728,7 @@ export default class MessageSender {
 | 
				
			||||||
      contentHint: ContentHint.DEFAULT,
 | 
					      contentHint: ContentHint.DEFAULT,
 | 
				
			||||||
      groupId: undefined,
 | 
					      groupId: undefined,
 | 
				
			||||||
      options,
 | 
					      options,
 | 
				
			||||||
      urgent: true,
 | 
					      urgent,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue