chore: send to client the contact info of who requested a call transfer. (#37150)

pull/37226/head
Pierre Lehnen 3 months ago committed by GitHub
parent 6d605e6a2c
commit 40e68e56dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      ee/packages/media-calls/src/internal/SignalProcessor.ts
  2. 4
      ee/packages/media-calls/src/internal/agents/UserActorAgent.ts
  3. 20
      ee/packages/media-calls/src/server/getNewCallTransferredBy.ts
  4. 1
      packages/media-signaling/src/definition/call/IClientMediaCall.ts
  5. 2
      packages/media-signaling/src/definition/signals/server/new.ts
  6. 8
      packages/media-signaling/src/lib/Call.ts

@ -14,6 +14,7 @@ import type { InternalCallParams } from '../definition/common';
import { logger } from '../logger';
import { mediaCallDirector } from '../server/CallDirector';
import { UserActorAgent } from './agents/UserActorAgent';
import { getNewCallTransferredBy } from '../server/getNewCallTransferredBy';
import { stripSensitiveDataFromSignal } from '../server/stripSensitiveData';
export type SignalProcessorEvents = {
@ -143,6 +144,8 @@ export class GlobalSignalProcessor {
await mediaCallDirector.renewCallId(call._id);
}
const transferredBy = getNewCallTransferredBy(call);
if (isCaller) {
this.sendSignal(uid, {
callId: call._id,
@ -157,6 +160,8 @@ export class GlobalSignalProcessor {
...call.callee,
},
...(call.callerRequestedId && { requestedCallId: call.callerRequestedId }),
...(call.parentCallId && { replacingCallId: call.parentCallId }),
...(transferredBy && { transferredBy }),
});
}
@ -173,6 +178,8 @@ export class GlobalSignalProcessor {
contact: {
...call.caller,
},
...(call.parentCallId && { replacingCallId: call.parentCallId }),
...(transferredBy && { transferredBy }),
});
}
@ -268,6 +275,8 @@ export class GlobalSignalProcessor {
this.rejectCallRequest(uid, { ...rejection, reason: 'already-requested' });
}
const transferredBy = getNewCallTransferredBy(call);
this.sendSignal(uid, {
callId: call._id,
type: 'new',
@ -281,6 +290,8 @@ export class GlobalSignalProcessor {
...call.callee,
},
requestedCallId: signal.callId,
...(call.parentCallId && { replacingCallId: call.parentCallId }),
...(transferredBy && { transferredBy }),
});
return call;

@ -5,6 +5,7 @@ import { MediaCallNegotiations, MediaCalls } from '@rocket.chat/models';
import { UserActorSignalProcessor } from './CallSignalProcessor';
import { BaseMediaCallAgent } from '../../base/BaseAgent';
import { logger } from '../../logger';
import { getNewCallTransferredBy } from '../../server/getNewCallTransferredBy';
import { getMediaCallServer } from '../../server/injection';
export class UserActorAgent extends BaseMediaCallAgent {
@ -167,6 +168,8 @@ export class UserActorAgent extends BaseMediaCallAgent {
}
protected buildNewCallSignal(call: IMediaCall): ServerMediaSignalNewCall {
const transferredBy = getNewCallTransferredBy(call);
return {
callId: call._id,
type: 'new',
@ -176,6 +179,7 @@ export class UserActorAgent extends BaseMediaCallAgent {
self: this.getMyCallActor(call),
contact: this.getOtherCallActor(call),
...(call.parentCallId && { replacingCallId: call.parentCallId }),
...(transferredBy && { transferredBy }),
...(call.callerRequestedId && this.role === 'caller' && { requestedCallId: call.callerRequestedId }),
};
}

@ -0,0 +1,20 @@
import type { IMediaCall } from '@rocket.chat/core-typings';
import type { CallContact } from '@rocket.chat/media-signaling';
export function getNewCallTransferredBy(call: IMediaCall): CallContact | null {
const { createdBy, parentCallId, caller, callee } = call;
if (!createdBy || !parentCallId) {
return null;
}
if (createdBy.type === caller.type && createdBy.id === caller.id) {
return null;
}
if (createdBy.type === callee.type && createdBy.id === callee.id) {
return null;
}
return createdBy;
}

@ -77,6 +77,7 @@ export interface IClientMediaCall {
busy: boolean;
contact: CallContact;
transferredBy: CallContact | null;
audioLevel: number;
localAudioLevel: number;

@ -15,4 +15,6 @@ export type ServerMediaSignalNewCall = {
requestedCallId?: string;
/** If this new call initiated from a transfer, this will hold the id of the call that was transferred */
replacingCallId?: string;
/** If this new call initiated from a transfer, this will hold the information of the user who requested the transfer */
transferredBy?: CallContact;
};

@ -78,6 +78,12 @@ export class ClientMediaCall implements IClientMediaCall {
return this._contact || {};
}
private _transferredBy: CallContact | null;
public get transferredBy(): CallContact | null {
return this._transferredBy;
}
private _service: CallService | null;
public get service(): CallService | null {
@ -200,6 +206,7 @@ export class ClientMediaCall implements IClientMediaCall {
this.oldClientState = 'none';
this._ignored = false;
this._contact = null;
this._transferredBy = null;
this._service = null;
}
@ -263,6 +270,7 @@ export class ClientMediaCall implements IClientMediaCall {
this._service = signal.service;
this._role = signal.role;
this._transferredBy = signal.transferredBy || null;
this.changeContact(signal.contact);
if (this._role === 'caller' && !this.acceptedLocally) {

Loading…
Cancel
Save