@@ -27,6 +27,7 @@ import {
2727 Ephemeral ,
2828 External ,
2929 GenericMessage ,
30+ Knock ,
3031 LastRead ,
3132 LegalHoldStatus ,
3233 MessageDelete ,
@@ -223,16 +224,42 @@ export class MessageRepository {
223224 * @returns Resolves after sending the knock
224225 */
225226 public async sendPing ( conversation : Conversation ) : Promise < void > {
226- const ping = this . core . service ! . conversation . messageBuilder . createPing ( {
227- conversationId : conversation . id ,
228- ping : {
229- expectsReadConfirmation : this . expectReadReceipt ( conversation ) ,
230- hotKnock : false ,
231- legalHoldStatus : conversation . legalHoldStatus ( ) ,
232- } ,
227+ if ( conversation . isFederated ( ) ) {
228+ const ping = this . core . service ! . conversation . messageBuilder . createPing ( {
229+ conversationId : conversation . id ,
230+ ping : {
231+ expectsReadConfirmation : this . expectReadReceipt ( conversation ) ,
232+ hotKnock : false ,
233+ legalHoldStatus : conversation . legalHoldStatus ( ) ,
234+ } ,
235+ } ) ;
236+
237+ this . sendAndInjectGenericCoreMessage ( ping , conversation , { playPingAudio : true } ) ;
238+ }
239+ const protoKnock = new Knock ( {
240+ [ PROTO_MESSAGE_TYPE . EXPECTS_READ_CONFIRMATION ] : this . expectReadReceipt ( conversation ) ,
241+ [ PROTO_MESSAGE_TYPE . LEGAL_HOLD_STATUS ] : conversation . legalHoldStatus ( ) ,
242+ hotKnock : false ,
243+ } ) ;
244+
245+ let genericMessage = new GenericMessage ( {
246+ [ GENERIC_MESSAGE_TYPE . KNOCK ] : protoKnock ,
247+ messageId : createRandomUuid ( ) ,
233248 } ) ;
234249
235- this . sendAndInjectGenericCoreMessage ( ping , conversation , { playPingAudio : true } ) ;
250+ if ( conversation . messageTimer ( ) ) {
251+ genericMessage = this . wrapInEphemeralMessage ( genericMessage , conversation . messageTimer ( ) ) ;
252+ }
253+
254+ try {
255+ await this . _sendAndInjectGenericMessage ( conversation , genericMessage ) ;
256+ } catch ( error ) {
257+ if ( ! this . isUserCancellationError ( error ) ) {
258+ this . logger . error ( `Error while sending knock: ${ error . message } ` , error ) ;
259+ throw error ;
260+ }
261+ }
262+ return undefined ;
236263 }
237264
238265 /**
0 commit comments