From 17ae781b6c4baec5ce1db2cfd0418be9ac8588bf Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 4 Jun 2024 17:05:59 -0300 Subject: [PATCH] allow apps engine to get discussions by room id --- src/definition/messages/IDiscussionMessage.ts | 7 ++++ src/server/bridges/RoomBridge.ts | 35 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/definition/messages/IDiscussionMessage.ts diff --git a/src/definition/messages/IDiscussionMessage.ts b/src/definition/messages/IDiscussionMessage.ts new file mode 100644 index 000000000..c692fb8ad --- /dev/null +++ b/src/definition/messages/IDiscussionMessage.ts @@ -0,0 +1,7 @@ +import { IMessage } from '.'; + +export interface IDiscussionMessage extends IMessage { + drid: string; + dlm?: Date; + dcount: number; +} diff --git a/src/server/bridges/RoomBridge.ts b/src/server/bridges/RoomBridge.ts index a1ec60952..a2e857739 100644 --- a/src/server/bridges/RoomBridge.ts +++ b/src/server/bridges/RoomBridge.ts @@ -1,4 +1,5 @@ import type { IMessage } from '../../definition/messages'; +import { IDiscussionMessage } from '../../definition/messages/IDiscussionMessage'; import type { IRoom } from '../../definition/rooms'; import type { IUser } from '../../definition/users'; import { PermissionDeniedError } from '../errors/PermissionDeniedError'; @@ -67,6 +68,25 @@ export abstract class RoomBridge extends BaseBridge { } } + public async doGetDiscussions( + roomId: string, + options: { + limit: number; + skip?: number; + sort?: Record; + }, + appId: string, + ): Promise<{ + messages: IDiscussionMessage[]; + count: number; + offset: number; + total: number; + }> { + if (this.hasReadPermission(appId)) { + return this.getDiscussions(roomId, options, appId); + } + } + public async doDelete(room: string, appId: string): Promise { if (this.hasWritePermission(appId)) { return this.delete(room, appId); @@ -129,6 +149,21 @@ export abstract class RoomBridge extends BaseBridge { appId: string, ): Promise; + protected abstract getDiscussions( + rid: string, + options: { + limit: number; + offset?: number; + sort?: Record; + }, + _appId: string, + ): Promise<{ + messages: IDiscussionMessage[]; + count: number; + offset: number; + total: number; + }>; + protected abstract delete(room: string, appId: string): Promise; protected abstract getModerators(roomId: string, appId: string): Promise>;