Skip to content

Commit

Permalink
feat(apps): bridge method for removing users of a room (#32706)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh authored Jul 12, 2024
1 parent 1b7b116 commit 16a9c86
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-queens-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

Added the possibility for apps to remove users from a room
15 changes: 11 additions & 4 deletions apps/meteor/app/apps/server/bridges/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createDirectMessage } from '../../../../server/methods/createDirectMess
import { createDiscussion } from '../../../discussion/server/methods/createDiscussion';
import { addUserToRoom } from '../../../lib/server/functions/addUserToRoom';
import { deleteRoom } from '../../../lib/server/functions/deleteRoom';
import { removeUserFromRoom } from '../../../lib/server/functions/removeUserFromRoom';
import { createChannelMethod } from '../../../lib/server/methods/createChannel';
import { createPrivateGroupMethod } from '../../../lib/server/methods/createPrivateGroup';

Expand Down Expand Up @@ -210,15 +211,21 @@ export class AppRoomBridge extends RoomBridge {
return users.map((user: ICoreUser) => userConverter.convertToApp(user));
}

protected async removeUsers(roomId: string, usernames: Array<string>, appId: string): Promise<void> {
this.orch.debugLog(`The App ${appId} is removing users ${usernames} from room id: ${roomId}`);
if (!roomId) {
throw new Error('roomId was not provided.');
}

const members = await Users.findUsersByUsernames(usernames, { limit: 50 }).toArray();
await Promise.all(members.map((user) => removeUserFromRoom(roomId, user)));
}

protected getMessages(
_roomId: string,
_options: { limit: number; skip?: number; sort?: Record<string, 1 | -1> },
_appId: string,
): Promise<IMessage[]> {
throw new Error('Method not implemented.');
}

protected removeUsers(_roomId: string, _usernames: Array<string>, _appId: string): Promise<void> {
throw new Error('Method not implemented.');
}
}
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.43.0",
"@rocket.chat/apps-engine": "alpha",
"@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.44.0-alpha.818",
"@rocket.chat/apps-engine": "alpha",
"@rocket.chat/base64": "workspace:^",
"@rocket.chat/cas-validate": "workspace:^",
"@rocket.chat/core-services": "workspace:^",
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.43.0",
"@rocket.chat/apps-engine": "alpha",
"@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.43.0",
"@rocket.chat/apps-engine": "alpha",
"@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.43.0",
"@rocket.chat/apps-engine": "alpha",
"@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.43.0",
"@rocket.chat/apps-engine": "alpha",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/icons": "^0.36.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 @@ -22,7 +22,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "1.43.0",
"@rocket.chat/apps-engine": "alpha",
"@rocket.chat/icons": "^0.36.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 @@ -63,7 +63,7 @@
"@babel/preset-env": "~7.22.20",
"@babel/preset-react": "~7.22.15",
"@babel/preset-typescript": "~7.22.15",
"@rocket.chat/apps-engine": "1.43.0",
"@rocket.chat/apps-engine": "alpha",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/eslint-config": "workspace:^",
"@rocket.chat/fuselage": "^0.55.2",
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 @@ -24,7 +24,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "1.43.0",
"@rocket.chat/apps-engine": "alpha",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/message-parser": "workspace:^",
"@rocket.chat/ui-kit": "workspace:~",
Expand Down
48 changes: 13 additions & 35 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8508,9 +8508,9 @@ __metadata:
languageName: unknown
linkType: soft

"@rocket.chat/apps-engine@npm:1.43.0":
version: 1.43.0
resolution: "@rocket.chat/apps-engine@npm:1.43.0"
"@rocket.chat/apps-engine@npm:alpha":
version: 1.44.0-alpha.814
resolution: "@rocket.chat/apps-engine@npm:1.44.0-alpha.814"
dependencies:
"@msgpack/msgpack": 3.0.0-beta2
adm-zip: ^0.5.9
Expand All @@ -8526,37 +8526,15 @@ __metadata:
uuid: ~8.3.2
peerDependencies:
"@rocket.chat/ui-kit": "*"
checksum: d2a4be96fd56bd7790459cbe82d87601ce8cb4e846a8cd5d1cddbc699ff776f3dcd07b3b22a7e74f12e2f1b0361b6c3cf4a415254f1f5d75d537f5c5730ce05e
languageName: node
linkType: hard

"@rocket.chat/apps-engine@npm:1.44.0-alpha.818":
version: 1.44.0-alpha.818
resolution: "@rocket.chat/apps-engine@npm:1.44.0-alpha.818"
dependencies:
"@msgpack/msgpack": 3.0.0-beta2
adm-zip: ^0.5.9
cryptiles: ^4.1.3
debug: ^4.3.4
deno-bin: 1.37.1
esbuild: ^0.20.2
jose: ^4.11.1
jsonrpc-lite: ^2.2.0
lodash.clonedeep: ^4.5.0
semver: ^5.7.1
stack-trace: 0.0.10
uuid: ~8.3.2
peerDependencies:
"@rocket.chat/ui-kit": "*"
checksum: acef47bc7f13e0682d018531638b5168c3acd59beae37b013e881ea6fadfe12670fe10545f4a89487f7bedbe9166028833cba7ed3fc401d4283327e47e00e61c
checksum: 03f777ecd035af20c88558a941db77bb104f4402f78169a6d23e1629613c11ac23c04f6bdfb451a4273558789de58d4567661a7bd5de91b78464f98698e5f6a6
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.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/model-typings": "workspace:^"
"@types/jest": ~29.5.7
Expand Down Expand Up @@ -8635,7 +8613,7 @@ __metadata:
"@babel/core": ~7.22.20
"@babel/preset-env": ~7.22.20
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ^0.36.0
Expand All @@ -8661,7 +8639,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/core-typings@workspace:packages/core-typings"
dependencies:
"@rocket.chat/apps-engine": 1.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ^0.36.0
"@rocket.chat/message-parser": "workspace:^"
Expand Down Expand Up @@ -8738,7 +8716,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/ddp-streamer@workspace:ee/apps/ddp-streamer"
dependencies:
"@rocket.chat/apps-engine": 1.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/emitter": ~0.31.25
Expand Down Expand Up @@ -8934,7 +8912,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.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/fuselage": ^0.55.2
Expand Down Expand Up @@ -9379,7 +9357,7 @@ __metadata:
"@rocket.chat/agenda": "workspace:^"
"@rocket.chat/api-client": "workspace:^"
"@rocket.chat/apps": "workspace:^"
"@rocket.chat/apps-engine": 1.44.0-alpha.818
"@rocket.chat/apps-engine": alpha
"@rocket.chat/base64": "workspace:^"
"@rocket.chat/cas-validate": "workspace:^"
"@rocket.chat/core-services": "workspace:^"
Expand Down Expand Up @@ -10017,7 +9995,7 @@ __metadata:
"@babel/core": ~7.22.20
"@babel/preset-env": ~7.22.20
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
Expand Down Expand Up @@ -10132,7 +10110,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/rest-typings@workspace:packages/rest-typings"
dependencies:
"@rocket.chat/apps-engine": 1.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/message-parser": "workspace:^"
Expand Down Expand Up @@ -37182,7 +37160,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "rocketchat-services@workspace:apps/meteor/ee/server/services"
dependencies:
"@rocket.chat/apps-engine": 1.43.0
"@rocket.chat/apps-engine": alpha
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/emitter": ~0.31.25
Expand Down

0 comments on commit 16a9c86

Please sign in to comment.