@@ -12,10 +12,11 @@ import { callServer, type IMediaCallServerSettings } from '@rocket.chat/media-ca
1212import { type CallFeature , isClientMediaSignal , type ClientMediaSignal , type ServerMediaSignal } from '@rocket.chat/media-signaling' ;
1313import type { InsertionModel } from '@rocket.chat/model-typings' ;
1414import { CallHistory , MediaCalls , Rooms , Users } from '@rocket.chat/models' ;
15- import { getHistoryMessagePayload } from '@rocket.chat/ui-voip/dist/ui-kit/getHistoryMessagePayload' ;
15+ import { callStateToTranslationKey , getHistoryMessagePayload } from '@rocket.chat/ui-voip/dist/ui-kit/getHistoryMessagePayload' ;
1616
1717import { sendMessage } from '../../../app/lib/server/functions/sendMessage' ;
1818import { settings } from '../../../app/settings/server' ;
19+ import { i18n } from '../../lib/i18n' ;
1920import { createDirectMessage } from '../../methods/createDirectMessage' ;
2021
2122const logger = new Logger ( 'media-call service' ) ;
@@ -187,6 +188,10 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall
187188 }
188189 }
189190
191+ private getLanguageForUser ( user : IUser ) : string {
192+ return user . language || settings . get ( 'Language' ) || 'en' ;
193+ }
194+
190195 private async sendHistoryMessage ( call : IMediaCall , room : IRoom ) : Promise < void > {
191196 const userId = call . caller . id || call . createdBy ?. id ; // I think this should always be the caller, since during a transfer the createdBy contact is the one that transferred the call
192197
@@ -196,12 +201,16 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall
196201 }
197202
198203 const state = this . getCallHistoryItemState ( call ) ;
204+ const skipNotifications = state !== 'not-answered' || call . hangupReason === 'rejected' ;
205+ const i18nKey = callStateToTranslationKey ( state ) . i18n ?. key ;
206+
207+ const msg = i18nKey ? i18n . t ( i18nKey , { lng : this . getLanguageForUser ( user ) } ) : '' ;
199208 const duration = this . getCallDuration ( call ) ;
200209
201- const record = getHistoryMessagePayload ( state , duration , call . _id ) ;
210+ const record = getHistoryMessagePayload ( state , duration , call . _id , msg ) ;
202211
203212 try {
204- const message = await sendMessage ( user , record , room ) ;
213+ const message = await sendMessage ( user , record , room , { skipNotifications } ) ;
205214
206215 if ( '_id' in message ) {
207216 await CallHistory . updateMany ( { callId : call . _id } , { $set : { messageId : message . _id } } ) ;
0 commit comments