Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/meteor/server/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
LoginServiceConfigurationRaw,
MediaCallsRaw,
MediaCallChannelsRaw,
MediaCallChannelLogsRaw,
MediaCallNegotiationsRaw,
MessageReadsRaw,
MessagesRaw,
Expand Down Expand Up @@ -135,6 +136,7 @@ registerModel('ILivechatVisitorsModel', new LivechatVisitorsRaw(db));
registerModel('ILoginServiceConfigurationModel', new LoginServiceConfigurationRaw(db));
registerModel('IMediaCallsModel', new MediaCallsRaw(db));
registerModel('IMediaCallChannelsModel', new MediaCallChannelsRaw(db));
registerModel('IMediaCallChannelLogsModel', new MediaCallChannelLogsRaw(db));
registerModel('IMediaCallNegotiationsModel', new MediaCallNegotiationsRaw(db));
registerModel('IMessageReadsModel', new MessageReadsRaw(db));
registerModel('IMessagesModel', new MessagesRaw(db, trashCollection));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
ClientMediaSignalLocalState,
ServerMediaSignal,
} from '@rocket.chat/media-signaling';
import { MediaCallChannels, MediaCallNegotiations, MediaCalls } from '@rocket.chat/models';
import { MediaCallChannelLogs, MediaCallChannels, MediaCallNegotiations, MediaCalls } from '@rocket.chat/models';

import type { IMediaCallAgent } from '../../definition/IMediaCallAgent';
import { logger } from '../../logger';
Expand Down Expand Up @@ -82,6 +82,14 @@ export class UserActorSignalProcessor {
public async processSignal(signal: ClientMediaSignal): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.processSignal', signal: stripSensitiveDataFromSignal(signal) });

void MediaCallChannelLogs.insertOne({
callId: this.callId,
channelId: this.channel._id,
direction: 'recv',
ts: new Date(),
content: signal,
}).catch(() => null);

// The code will only reach this point if one of the following conditions are true:
// 1. the signal came from the exact user session where the caller initiated the call
// 2. the signal came from the exact user session where the callee accepted the call
Expand Down Expand Up @@ -271,6 +279,14 @@ export class UserActorSignalProcessor {
}

protected async sendSignal(signal: ServerMediaSignal): Promise<void> {
void MediaCallChannelLogs.insertOne({
callId: this.callId,
channelId: this.channel._id,
direction: 'send',
ts: new Date(),
content: signal,
}).catch(() => null);

getMediaCallServer().sendSignal(this.actorId, signal);
}

Expand Down
13 changes: 13 additions & 0 deletions packages/core-typings/src/mediaCalls/IMediaCallChannelLog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { IRocketChatRecord } from '../IRocketChatRecord';

export interface IMediaCallChannelLog extends IRocketChatRecord {
callId: string;

channelId: string;

direction: 'send' | 'recv';

ts: Date;

content: Record<string, any>;
}
1 change: 1 addition & 0 deletions packages/core-typings/src/mediaCalls/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './IMediaCall';
export * from './IMediaCallChannel';
export * from './IMediaCallChannelLog';
export * from './IMediaCallNegotiation';
1 change: 1 addition & 0 deletions packages/model-typings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export * from './models/IMigrationsModel';
export * from './models/IModerationReportsModel';
export * from './models/IMediaCallsModel';
export * from './models/IMediaCallChannelsModel';
export * from './models/IMediaCallChannelLogsModel';
export * from './models/IMediaCallNegotiationsModel';
export * from './updater';
export * from './models/IWorkspaceCredentialsModel';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { IMediaCallChannelLog } from '@rocket.chat/core-typings';

import type { IBaseModel } from './IBaseModel';

export type IMediaCallChannelLogsModel = IBaseModel<IMediaCallChannelLog>;
2 changes: 2 additions & 0 deletions packages/models/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import type {
IFreeSwitchChannelEventDeltaModel,
IMediaCallsModel,
IMediaCallChannelsModel,
IMediaCallChannelLogsModel,
IMediaCallNegotiationsModel,
} from '@rocket.chat/model-typings';
import type { Collection, Db } from 'mongodb';
Expand Down Expand Up @@ -183,6 +184,7 @@ export const LoginServiceConfiguration = proxify<ILoginServiceConfigurationModel
export const Messages = proxify<IMessagesModel>('IMessagesModel');
export const MediaCalls = proxify<IMediaCallsModel>('IMediaCallsModel');
export const MediaCallChannels = proxify<IMediaCallChannelsModel>('IMediaCallChannelsModel');
export const MediaCallChannelLogs = proxify<IMediaCallChannelLogsModel>('IMediaCallChannelLogsModel');
export const MediaCallNegotiations = proxify<IMediaCallNegotiationsModel>('IMediaCallNegotiationsModel');
export const NotificationQueue = proxify<INotificationQueueModel>('INotificationQueueModel');
export const Nps = proxify<INpsModel>('INpsModel');
Expand Down
1 change: 1 addition & 0 deletions packages/models/src/modelClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export * from './models/Migrations';
export * from './models/ModerationReports';
export * from './models/MediaCalls';
export * from './models/MediaCallChannels';
export * from './models/MediaCallChannelLogs';
export * from './models/MediaCallNegotiations';
export * from './models/WorkspaceCredentials';
export * from './models/Trash';
22 changes: 22 additions & 0 deletions packages/models/src/models/MediaCallChannelLogs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { IMediaCallChannelLog, RocketChatRecordDeleted } from '@rocket.chat/core-typings';
import type { IMediaCallChannelLogsModel } from '@rocket.chat/model-typings';
import type { IndexDescription, Collection, Db } from 'mongodb';

import { BaseRaw } from './BaseRaw';

export class MediaCallChannelLogsRaw extends BaseRaw<IMediaCallChannelLog> implements IMediaCallChannelLogsModel {
constructor(db: Db, trash?: Collection<RocketChatRecordDeleted<IMediaCallChannelLog>>) {
super(db, 'media_call_channel_logs', trash);
}

protected modelIndexes(): IndexDescription[] {
return [
{
key: { callId: 1, channelId: 1 },
unique: false,
},
// Allow 3 days of events to be saved
{ key: { ts: 1 }, expireAfterSeconds: 3 * 24 * 60 * 60 },
];
}
}
Loading