Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/tiny-toes-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Introduced new methods for Rocket.Chat Apps to interact with livechat: `findOpenRoomsByAgentId` and `countOpenRoomsByAgentId`
21 changes: 21 additions & 0 deletions apps/meteor/app/apps/server/bridges/livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ export class AppLivechatBridge extends LivechatBridge {
return true;
}

protected async findOpenRoomsByAgentId(agentId: string, appId: string): Promise<ILivechatRoom[]> {
this.orch.debugLog(`The App ${appId} is looking for livechat rooms associated with agent ${agentId}`);

if (!agentId) {
Comment thread
lmauromb marked this conversation as resolved.
throw new Error('Invalid agentId');
}

const rooms = await LivechatRooms.findOpenByAgent(agentId).toArray();
return Promise.all(rooms.map((room) => this.orch.getConverters()?.get('rooms').convertRoom(room) as Promise<ILivechatRoom>));
}

protected async countOpenRoomsByAgentId(agentId: string, appId: string): Promise<number> {
this.orch.debugLog(`The App ${appId} is counting livechat rooms associated with agent ${agentId}`);

if (!agentId) {
Comment thread
lmauromb marked this conversation as resolved.
throw new Error('Invalid agentId');
}

return LivechatRooms.countOpenByAgent(agentId);
}

protected async findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise<Array<ILivechatRoom>> {
this.orch.debugLog(`The App ${appId} is looking for livechat visitors.`);

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"author": "Rocket.Chat",
"license": "MIT",
"dependencies": {
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/core-services": "workspace:^",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.25",
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"@rocket.chat/agenda": "workspace:^",
"@rocket.chat/api-client": "workspace:^",
"@rocket.chat/apps": "workspace:^",
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/base64": "workspace:^",
"@rocket.chat/cas-validate": "workspace:^",
"@rocket.chat/core-services": "workspace:^",
Expand Down
11 changes: 11 additions & 0 deletions apps/meteor/server/models/raw/LivechatRooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,17 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
);
}

countOpenByAgent(userId: string, extraQuery: Filter<IOmnichannelRoom> = {}) {
Comment thread
lmauromb marked this conversation as resolved.
const query: Filter<IOmnichannelRoom> = {
't': 'l',
'open': true,
'servedBy._id': userId,
...extraQuery,
};

return this.col.countDocuments(query);
}

findOpenByAgent(userId: string, extraQuery: Filter<IOmnichannelRoom> = {}) {
const query: Filter<IOmnichannelRoom> = {
't': 'l',
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/ddp-streamer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"author": "Rocket.Chat",
"dependencies": {
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/core-services": "workspace:^",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.25",
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/presence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@babel/core": "~7.22.20",
"@babel/preset-env": "~7.22.20",
"@babel/preset-typescript": "~7.22.15",
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/eslint-config": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
"@types/node": "^14.18.63",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "^1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/model-typings": "workspace:^"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"extends": "../../package.json"
},
"dependencies": {
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/icons": "^0.33.0",
"@rocket.chat/message-parser": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/icons": "^0.33.0",
"@rocket.chat/message-parser": "workspace:^",
"@rocket.chat/ui-kit": "workspace:~"
Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage-ui-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@babel/preset-env": "~7.22.20",
"@babel/preset-react": "~7.22.15",
"@babel/preset-typescript": "~7.22.15",
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/eslint-config": "workspace:^",
"@rocket.chat/fuselage": "^0.50.1",
"@rocket.chat/fuselage-hooks": "^0.33.0",
Expand Down
1 change: 1 addition & 0 deletions packages/model-typings/src/models/ILivechatRoomsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export interface ILivechatRoomsModel extends IBaseModel<IOmnichannelRoom> {
data?: { departmentId: string },
): AggregationCursor<Pick<IOmnichannelRoom, 'ts' | 'departmentId' | 'open' | 'servedBy' | 'metrics' | 'msgs' | 'onHold'>>;
findOpenByAgent(userId: string, extraQuery?: Filter<IOmnichannelRoom>): FindCursor<IOmnichannelRoom>;
countOpenByAgent(userId: string, extraQuery?: Filter<IOmnichannelRoom>): Promise<number>;
changeAgentByRoomId(roomId: string, newAgent: { agentId: string; username: string }): Promise<UpdateResult>;
changeDepartmentIdByRoomId(roomId: string, departmentId: string): Promise<UpdateResult>;
saveCRMDataByRoomId(roomId: string, crmData: unknown): Promise<UpdateResult>;
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/apps-engine": "1.42.0-alpha.619",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/message-parser": "workspace:^",
"@rocket.chat/ui-kit": "workspace:~",
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8331,9 +8331,9 @@ __metadata:
languageName: unknown
linkType: soft

"@rocket.chat/apps-engine@npm:1.41.0, @rocket.chat/apps-engine@npm:^1.41.0":
version: 1.41.0
resolution: "@rocket.chat/apps-engine@npm:1.41.0"
"@rocket.chat/apps-engine@npm:1.42.0-alpha.619":
version: 1.42.0-alpha.619
resolution: "@rocket.chat/apps-engine@npm:1.42.0-alpha.619"
dependencies:
adm-zip: ^0.5.9
cryptiles: ^4.1.3
Expand All @@ -8345,15 +8345,15 @@ __metadata:
vm2: ^3.9.19
peerDependencies:
"@rocket.chat/ui-kit": "*"
checksum: 2e7fa2856bdbdc6b0dd2456e9aa5e5804a4198f8df0306a002c5e71681466d3fc2cb0a1253668d5e24fa21345a7dd7eed3458a257e1e4cc59a4e8a3876579aa5
checksum: 9acf0a435ec08bc17089dfe1852487d160a74e94e31fb7d541b3bba11f51bbd2a3c6cf7ca9546174f7f8b2ae82b9558069647e48e0eda4b48d31c8ed9d40aa54
languageName: node
linkType: hard

"@rocket.chat/apps@workspace:^, @rocket.chat/apps@workspace:packages/apps":
version: 0.0.0-use.local
resolution: "@rocket.chat/apps@workspace:packages/apps"
dependencies:
"@rocket.chat/apps-engine": ^1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/model-typings": "workspace:^"
"@types/jest": ~29.5.7
Expand Down Expand Up @@ -8432,7 +8432,7 @@ __metadata:
"@babel/core": ~7.22.20
"@babel/preset-env": ~7.22.20
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ^0.33.0
Expand All @@ -8458,7 +8458,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/core-typings@workspace:packages/core-typings"
dependencies:
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ^0.33.0
"@rocket.chat/message-parser": "workspace:^"
Expand Down Expand Up @@ -8535,7 +8535,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/ddp-streamer@workspace:ee/apps/ddp-streamer"
dependencies:
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/emitter": ~0.31.25
Expand Down Expand Up @@ -8730,7 +8730,7 @@ __metadata:
"@babel/preset-env": ~7.22.20
"@babel/preset-react": ~7.22.15
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/fuselage": ^0.50.1
"@rocket.chat/fuselage-hooks": ^0.33.0
Expand Down Expand Up @@ -9166,7 +9166,7 @@ __metadata:
"@rocket.chat/agenda": "workspace:^"
"@rocket.chat/api-client": "workspace:^"
"@rocket.chat/apps": "workspace:^"
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/base64": "workspace:^"
"@rocket.chat/cas-validate": "workspace:^"
"@rocket.chat/core-services": "workspace:^"
Expand Down Expand Up @@ -9788,7 +9788,7 @@ __metadata:
"@babel/core": ~7.22.20
"@babel/preset-env": ~7.22.20
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
Expand Down Expand Up @@ -9903,7 +9903,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/rest-typings@workspace:packages/rest-typings"
dependencies:
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/message-parser": "workspace:^"
Expand Down Expand Up @@ -36180,7 +36180,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "rocketchat-services@workspace:apps/meteor/ee/server/services"
dependencies:
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/apps-engine": 1.42.0-alpha.619
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/emitter": ~0.31.25
Expand Down