Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: remove deprecated meteor eraseRoom method #32648

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/chilled-boats-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

This adjustment removes the deprecated `eraseRoom` method. Moving forward, use the `room.delete` endpoint to delete rooms.
3 changes: 2 additions & 1 deletion apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Meteor } from 'meteor/meteor';

import { isTruthy } from '../../../../lib/isTruthy';
import { findUsersOfRoom } from '../../../../server/lib/findUsersOfRoom';
import { eraseRoom } from '../../../../server/methods/eraseRoom';
import { hideRoomMethod } from '../../../../server/methods/hideRoom';
import { removeUserFromRoomMethod } from '../../../../server/methods/removeUserFromRoom';
import { canAccessRoomAsync } from '../../../authorization/server';
Expand Down Expand Up @@ -463,7 +464,7 @@ API.v1.addRoute(
checkedArchived: false,
});

await Meteor.callAsync('eraseRoom', room._id);
await eraseRoom(room._id, this.userId);

return API.v1.success();
},
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/api/server/v1/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Meteor } from 'meteor/meteor';
import type { Filter } from 'mongodb';

import { findUsersOfRoom } from '../../../../server/lib/findUsersOfRoom';
import { eraseRoom } from '../../../../server/methods/eraseRoom';
import { hideRoomMethod } from '../../../../server/methods/hideRoom';
import { removeUserFromRoomMethod } from '../../../../server/methods/removeUserFromRoom';
import { canAccessRoomAsync, roomAccessAttributes } from '../../../authorization/server';
Expand Down Expand Up @@ -364,7 +365,7 @@ API.v1.addRoute(
checkedArchived: false,
});

await Meteor.callAsync('eraseRoom', findResult.rid);
await eraseRoom(findResult.rid, this.userId);

return API.v1.success();
},
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/app/api/server/v1/im.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Match, check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';

import { createDirectMessage } from '../../../../server/methods/createDirectMessage';
import { eraseRoom } from '../../../../server/methods/eraseRoom';
import { hideRoomMethod } from '../../../../server/methods/hideRoom';
import { canAccessRoomIdAsync } from '../../../authorization/server/functions/canAccessRoom';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
Expand All @@ -26,6 +27,7 @@ import { API } from '../api';
import { addUserToFileObj } from '../helpers/addUserToFileObj';
import { composeRoomWithLastMessage } from '../helpers/composeRoomWithLastMessage';
import { getPaginationItems } from '../helpers/getPaginationItems';

// TODO: Refact or remove

type findDirectMessageRoomProps =
Expand Down Expand Up @@ -107,7 +109,7 @@ API.v1.addRoute(
throw new Meteor.Error('error-not-allowed', 'Not allowed');
}

await Meteor.callAsync('eraseRoom', room._id);
await eraseRoom(room._id, this.userId);

return API.v1.success();
},
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/api/server/v1/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
} from '@rocket.chat/rest-typings';
import { escapeRegExp } from '@rocket.chat/string-helpers';
import { Match, check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';

import { eraseRoom } from '../../../../server/methods/eraseRoom';
import { canAccessRoomAsync } from '../../../authorization/server';
import { hasPermissionAsync, hasAtLeastOnePermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { removeUserFromRoom } from '../../../lib/server/functions/removeUserFromRoom';
Expand Down Expand Up @@ -135,7 +135,7 @@ API.v1.addRoute(

if (rooms.length) {
for await (const room of rooms) {
await Meteor.callAsync('eraseRoom', room);
await eraseRoom(room, this.userId);
}
}

Expand Down Expand Up @@ -613,15 +613,15 @@ API.v1.addRoute(
// If we got a list of rooms to delete along with the team, remove them first
if (rooms.length) {
for await (const room of rooms) {
await Meteor.callAsync('eraseRoom', room);
await eraseRoom(room, this.userId);
}
}

// Move every other room back to the workspace
await Team.unsetTeamIdOfRooms(this.userId, team._id);

// Remove the team's main room
await Meteor.callAsync('eraseRoom', team.roomId);
await eraseRoom(team.roomId, this.userId);

// Delete all team memberships
await Team.removeAllMembersFromTeam(team._id);
Expand Down
29 changes: 0 additions & 29 deletions apps/meteor/server/methods/eraseRoom.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { AppEvents, Apps } from '@rocket.chat/apps';
import { Message, Team } from '@rocket.chat/core-services';
import type { ServerMethods } from '@rocket.chat/ddp-client';

Check failure on line 3 in apps/meteor/server/methods/eraseRoom.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

'ServerMethods' is defined but never used
import { Rooms } from '@rocket.chat/models';
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';

import { hasPermissionAsync } from '../../app/authorization/server/functions/hasPermission';
import { deleteRoom } from '../../app/lib/server/functions/deleteRoom';
import { methodDeprecationLogger } from '../../app/lib/server/lib/deprecationWarningLogger';
import { roomCoordinator } from '../lib/rooms/roomCoordinator';

export async function eraseRoom(rid: string, uid: string): Promise<void> {
Expand Down Expand Up @@ -57,30 +55,3 @@
void Apps.getBridges()?.getListenerBridge().roomEvent(AppEvents.IPostRoomDeleted, room);
}
}

declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
eraseRoom(rid: string): Promise<boolean>;
}
}

Meteor.methods<ServerMethods>({
async eraseRoom(rid: string) {
methodDeprecationLogger.method('eraseRoom', '7.0.0');

check(rid, String);

const uid = Meteor.userId();

if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'eraseRoom',
});
}

await eraseRoom(rid, uid);

return true;
},
});
Loading