From d5aa91cb72e3944816dc5deac28abac03082d7f6 Mon Sep 17 00:00:00 2001 From: Dnouv Date: Thu, 26 Sep 2024 17:22:27 +0530 Subject: [PATCH] remove 'room' --- src/definition/accessors/IRoomRead.ts | 4 ++-- src/server/accessors/RoomRead.ts | 8 ++++---- src/server/bridges/RoomBridge.ts | 12 ++++++------ tests/server/accessors/RoomRead.spec.ts | 10 +++++----- tests/test-data/bridges/roomBridge.ts | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/definition/accessors/IRoomRead.ts b/src/definition/accessors/IRoomRead.ts index 51d34e82b..d4031f372 100644 --- a/src/definition/accessors/IRoomRead.ts +++ b/src/definition/accessors/IRoomRead.ts @@ -102,12 +102,12 @@ export interface IRoomRead { * - sort: An object defining the sorting order of the messages. Each key is a field to sort by, and the value is either 'asc' for ascending order or 'desc' for descending order. * @returns A Promise that resolves to an array of IMessage objects representing the unread messages for the specified user in the specified room. */ - getUnreadByRoomAndUser(roomId: string, uid: string, options?: Partial): Promise; + getUnreadByUser(roomId: string, uid: string, options?: Partial): Promise; /** * Gets the user's unread messages count in a room. * @param uid user's id * @param roomId room's id */ - getUserUnreadMessageCountByRoom(uid: string, roomId: string): Promise; + getUserUnreadMessageCount(uid: string, roomId: string): Promise; } diff --git a/src/server/accessors/RoomRead.ts b/src/server/accessors/RoomRead.ts index e2742a3ba..dd5a3ebd5 100644 --- a/src/server/accessors/RoomRead.ts +++ b/src/server/accessors/RoomRead.ts @@ -58,7 +58,7 @@ export class RoomRead implements IRoomRead { return this.roomBridge.doGetLeaders(roomId, this.appId); } - public async getUnreadByRoomAndUser(roomId: string, uid: string, options: Partial = {}): Promise { + public async getUnreadByUser(roomId: string, uid: string, options: Partial = {}): Promise { const { limit = 100, sort = { createdAt: 'asc' }, skip = 0 } = options; if (typeof roomId !== 'string' || roomId.trim().length === 0) { @@ -73,11 +73,11 @@ export class RoomRead implements IRoomRead { const completeOptions: GetMessagesOptions = { limit, sort, skip }; - return this.roomBridge.doGetUnreadByRoomAndUser(roomId, uid, completeOptions, this.appId); + return this.roomBridge.doGetUnreadByUser(roomId, uid, completeOptions, this.appId); } - public getUserUnreadMessageCountByRoom(uid: string, rid: string): Promise { - return this.roomBridge.doGetUserUnreadMessageCountByRoom(uid, rid, this.appId); + public getUserUnreadMessageCount(uid: string, rid: string): Promise { + return this.roomBridge.doGetUserUnreadMessageCount(uid, rid, this.appId); } // If there are any invalid fields or values, throw diff --git a/src/server/bridges/RoomBridge.ts b/src/server/bridges/RoomBridge.ts index b9f54dee3..94cf03543 100644 --- a/src/server/bridges/RoomBridge.ts +++ b/src/server/bridges/RoomBridge.ts @@ -111,15 +111,15 @@ export abstract class RoomBridge extends BaseBridge { } } - public async doGetUnreadByRoomAndUser(roomId: string, uid: string, options: GetMessagesOptions, appId: string): Promise { + public async doGetUnreadByUser(roomId: string, uid: string, options: GetMessagesOptions, appId: string): Promise { if (this.hasReadPermission(appId)) { - return this.getUnreadByRoomAndUser(roomId, uid, options, appId); + return this.getUnreadByUser(roomId, uid, options, appId); } } - public async doGetUserUnreadMessageCountByRoom(uid: string, roomId: string, appId: string): Promise { + public async doGetUserUnreadMessageCount(uid: string, roomId: string, appId: string): Promise { if (this.hasReadPermission(appId)) { - return this.getUserUnreadMessageCountByRoom(uid, roomId, appId); + return this.getUserUnreadMessageCount(uid, roomId, appId); } } @@ -159,9 +159,9 @@ export abstract class RoomBridge extends BaseBridge { protected abstract removeUsers(roomId: string, usernames: Array, appId: string): Promise; - protected abstract getUnreadByRoomAndUser(roomId: string, uid: string, options: GetMessagesOptions, appId: string): Promise; + protected abstract getUnreadByUser(roomId: string, uid: string, options: GetMessagesOptions, appId: string): Promise; - protected abstract getUserUnreadMessageCountByRoom(uid: string, roomId: string, appId: string): Promise; + protected abstract getUserUnreadMessageCount(uid: string, roomId: string, appId: string): Promise; private hasWritePermission(appId: string): boolean { if (AppPermissionManager.hasPermission(appId, AppPermissions.room.write)) { diff --git a/tests/server/accessors/RoomRead.spec.ts b/tests/server/accessors/RoomRead.spec.ts index 50600f868..d197b9889 100644 --- a/tests/server/accessors/RoomRead.spec.ts +++ b/tests/server/accessors/RoomRead.spec.ts @@ -57,7 +57,7 @@ export class RoomReadAccessorTestFixture { doGetMessages(roomId, options, appId): Promise { return Promise.resolve(theMessages); }, - doGetUnreadByRoomAndUser(roomId, uid, options, appId): Promise { + doGetUnreadByUser(roomId, uid, options, appId): Promise { if (roomId === unreadRoomId && uid === unreadUserId) { return Promise.resolve(theUnreadMsg); } @@ -84,11 +84,11 @@ export class RoomReadAccessorTestFixture { Expect(await rr.getDirectByUsernames([this.user.username])).toBe(this.room); Expect(await rr.getMessages('testing')).toBeDefined(); Expect(await rr.getMessages('testing')).toBe(this.messages); - Expect(await rr.getUnreadByRoomAndUser(this.unreadRoomId, this.unreadUserId)).toBeDefined(); - Expect(await rr.getUnreadByRoomAndUser(this.unreadRoomId, this.unreadUserId)).toEqual(this.messages); + Expect(await rr.getUnreadByUser(this.unreadRoomId, this.unreadUserId)).toBeDefined(); + Expect(await rr.getUnreadByUser(this.unreadRoomId, this.unreadUserId)).toEqual(this.messages); - Expect(await rr.getUnreadByRoomAndUser('fake', 'fake')).toBeDefined(); - Expect(await rr.getUnreadByRoomAndUser('fake', 'fake')).toEqual([]); + Expect(await rr.getUnreadByUser('fake', 'fake')).toBeDefined(); + Expect(await rr.getUnreadByUser('fake', 'fake')).toEqual([]); } @AsyncTest() diff --git a/tests/test-data/bridges/roomBridge.ts b/tests/test-data/bridges/roomBridge.ts index 7f5a79fb1..a9f70942c 100644 --- a/tests/test-data/bridges/roomBridge.ts +++ b/tests/test-data/bridges/roomBridge.ts @@ -65,11 +65,11 @@ export class TestsRoomBridge extends RoomBridge { throw new Error('Method not implemented'); } - public getUnreadByRoomAndUser(roomId: string, uid: string, options: GetMessagesOptions, appId: string): Promise { + public getUnreadByUser(roomId: string, uid: string, options: GetMessagesOptions, appId: string): Promise { throw new Error('Method not implemented.'); } - protected getUserUnreadMessageCountByRoom(uid: string, roomId: string, appId: string): Promise { + protected getUserUnreadMessageCount(uid: string, roomId: string, appId: string): Promise { throw new Error('Method not implemented.'); } }