diff --git a/src/definition/accessors/ILivechatRead.ts b/src/definition/accessors/ILivechatRead.ts index 6a7650949..91bdd487e 100644 --- a/src/definition/accessors/ILivechatRead.ts +++ b/src/definition/accessors/ILivechatRead.ts @@ -17,6 +17,8 @@ export interface ILivechatRead { isOnlineAsync(departmentId?: string): Promise; getDepartmentsEnabledWithAgents(): Promise>; getLivechatRooms(visitor: IVisitor, departmentId?: string): Promise>; + getLivechatRoomsByAgentId(agentId: string): Promise>; + getLivechatTotalRoomsByAgentId(agentId: string): Promise; /** * @deprecated This method does not adhere to the conversion practices applied * elsewhere in the Apps-Engine and will be removed in the next major version. diff --git a/src/server/accessors/LivechatRead.ts b/src/server/accessors/LivechatRead.ts index d58a4a531..ef7503976 100644 --- a/src/server/accessors/LivechatRead.ts +++ b/src/server/accessors/LivechatRead.ts @@ -30,6 +30,14 @@ export class LivechatRead implements ILivechatRead { return this.livechatBridge.doFindRooms(visitor, departmentId, this.appId); } + public getLivechatTotalRoomsByAgentId(agentId: string): Promise { + return this.livechatBridge.doCountRoomsByAgentId(agentId, this.appId); + } + + public getLivechatRoomsByAgentId(agentId: string): Promise> { + return this.livechatBridge.doFindRoomsByAgentId(agentId, this.appId); + } + /** * @deprecated This method does not adhere to the conversion practices applied * elsewhere in the Apps-Engine and will be removed in the next major version. diff --git a/src/server/bridges/LivechatBridge.ts b/src/server/bridges/LivechatBridge.ts index 48ab69942..8ca7b542f 100644 --- a/src/server/bridges/LivechatBridge.ts +++ b/src/server/bridges/LivechatBridge.ts @@ -104,6 +104,18 @@ export abstract class LivechatBridge extends BaseBridge { } } + public async doCountRoomsByAgentId(agentId: string, appId: string): Promise { + if (this.hasReadPermission(appId, 'livechat-room')) { + return this.countRoomsByAgentId(agentId, appId); + } + } + + public async doFindRoomsByAgentId(agentId: string, appId: string): Promise> { + if (this.hasReadPermission(appId, 'livechat-room')) { + return this.findRoomsByAgentId(agentId, appId); + } + } + public async doFindRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise> { if (this.hasReadPermission(appId, 'livechat-room')) { return this.findRooms(visitor, departmentId, appId); @@ -171,6 +183,10 @@ export abstract class LivechatBridge extends BaseBridge { protected abstract closeRoom(room: ILivechatRoom, comment: string, closer: IUser | undefined, appId: string): Promise; + protected abstract countRoomsByAgentId(agentId: string, appId: string): Promise; + + protected abstract findRoomsByAgentId(agentId: string, appId: string): Promise>; + protected abstract findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise>; protected abstract findDepartmentByIdOrName(value: string, appId: string): Promise; diff --git a/tests/test-data/bridges/livechatBridge.ts b/tests/test-data/bridges/livechatBridge.ts index c9beb66f4..9898be1ae 100644 --- a/tests/test-data/bridges/livechatBridge.ts +++ b/tests/test-data/bridges/livechatBridge.ts @@ -70,6 +70,14 @@ export class TestLivechatBridge extends LivechatBridge { throw new Error('Method not implemented'); } + public findRoomsByAgentId(agentId: string, appId: string): Promise { + throw new Error('Method not implemented'); + } + + public countRoomsByAgentId(agentId: string, appId: string): Promise { + throw new Error('Method not implemented'); + } + public findDepartmentByIdOrName(value: string, appId: string): Promise { throw new Error('Method not implemented'); }