Skip to content

Commit 017a166

Browse files
committed
chore: log deprecation for DDP methods replaced or unused
Adds methodDeprecationLogger.method() calls to 148 Meteor methods that are either orphan (no caller found in the repo) or already have a REST endpoint replacement. Methods with the call now warn that they will be removed in 9.0.0, and when applicable point to the replacement endpoint. Methods still in use without a REST equivalent are intentionally left untouched until a replacement endpoint exists. Already-deprecated methods (sendFileMessage, starMessage, insertOrUpdateSound, uploadCustomSound) are kept as-is. Generated by scripts/add-ddp-deprecation.mjs from docs/ddp-audit.json.
1 parent 609ade8 commit 017a166

134 files changed

Lines changed: 298 additions & 6 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/meteor/app/2fa/server/methods/disable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client';
22
import { Users } from '@rocket.chat/models';
33
import { Meteor } from 'meteor/meteor';
44

5+
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
56
import { notifyOnUserChange } from '../../../lib/server/lib/notifyListener';
67
import { TOTP } from '../lib/totp';
78

@@ -14,6 +15,7 @@ declare module '@rocket.chat/ddp-client' {
1415

1516
Meteor.methods<ServerMethods>({
1617
async '2fa:disable'(code) {
18+
methodDeprecationLogger.method('2fa:disable', '9.0.0', '/v1/users.2fa.sendEmailCode');
1719
const userId = Meteor.userId();
1820
if (!userId) {
1921
throw new Meteor.Error('not-authorized');

apps/meteor/app/2fa/server/methods/enable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client';
22
import { Users } from '@rocket.chat/models';
33
import { Meteor } from 'meteor/meteor';
44

5+
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
56
import { TOTP } from '../lib/totp';
67

78
declare module '@rocket.chat/ddp-client' {
@@ -13,6 +14,7 @@ declare module '@rocket.chat/ddp-client' {
1314

1415
Meteor.methods<ServerMethods>({
1516
async '2fa:enable'() {
17+
methodDeprecationLogger.method('2fa:enable', '9.0.0', '/v1/users.2fa.enableEmail');
1618
const userId = Meteor.userId();
1719
if (!userId) {
1820
throw new Meteor.Error('not-authorized');

apps/meteor/app/authorization/server/streamer/permissions/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { check, Match } from 'meteor/check';
55
import { Meteor } from 'meteor/meteor';
66
import type { WithId } from 'mongodb';
77

8+
import { methodDeprecationLogger } from '../../../../lib/server/lib/deprecationWarningLogger';
9+
810
declare module '@rocket.chat/ddp-client' {
911
// eslint-disable-next-line @typescript-eslint/naming-convention
1012
interface ServerMethods {
@@ -31,6 +33,7 @@ export const permissionsGetMethod = async (
3133

3234
Meteor.methods<ServerMethods>({
3335
async 'permissions/get'(updatedAt?: Date) {
36+
methodDeprecationLogger.method('permissions/get', '9.0.0', []);
3437
check(updatedAt, Match.Maybe(Date));
3538
// TODO: should we return this for non logged users?
3639
// TODO: we could cache this collection

apps/meteor/app/autotranslate/server/methods/saveSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ServerMethods } from '@rocket.chat/ddp-client';
22
import { Meteor } from 'meteor/meteor';
33

4+
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
45
import { saveAutoTranslateSettings } from '../functions/saveSettings';
56

67
declare module '@rocket.chat/ddp-client' {
@@ -12,6 +13,7 @@ declare module '@rocket.chat/ddp-client' {
1213

1314
Meteor.methods<ServerMethods>({
1415
async 'autoTranslate.saveSettings'(rid, field, value, options) {
16+
methodDeprecationLogger.method('autoTranslate.saveSettings', '9.0.0', []);
1517
const userId = Meteor.userId();
1618
if (!userId) {
1719
throw new Meteor.Error('error-invalid-user', 'Invalid user', {

apps/meteor/app/bot-helpers/server/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { removeUserFromRoomMethod } from '../../../server/methods/removeUserFrom
99
import { hasRoleAsync } from '../../authorization/server/functions/hasRole';
1010
import { addUserToRole } from '../../authorization/server/methods/addUserToRole';
1111
import { removeUserFromRole } from '../../authorization/server/methods/removeUserFromRole';
12+
import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger';
1213
import { addUsersToRoomMethod } from '../../lib/server/methods/addUsersToRoom';
1314
import { settings } from '../../settings/server';
1415

@@ -205,6 +206,7 @@ declare module '@rocket.chat/ddp-client' {
205206

206207
Meteor.methods<ServerMethods>({
207208
async botRequest(...args) {
209+
methodDeprecationLogger.method('botRequest', '9.0.0', []);
208210
const userID = Meteor.userId();
209211
if (userID && (await hasRoleAsync(userID, 'bot'))) {
210212
return botHelpers.request(...args, userID);

apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { roomCoordinator } from '../../../../server/lib/rooms/roomCoordinator';
1111
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
1212
import { isABACManagedRoom } from '../../../authorization/server/lib/isABACManagedRoom';
1313
import { setRoomAvatar } from '../../../lib/server/functions/setRoomAvatar';
14+
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
1415
import { notifyOnRoomChangedById } from '../../../lib/server/lib/notifyListener';
1516
import { settings } from '../../../settings/server';
1617
import { saveReactWhenReadOnly } from '../functions/saveReactWhenReadOnly';
@@ -547,6 +548,7 @@ export async function saveRoomSettings(
547548

548549
Meteor.methods<ServerMethods>({
549550
saveRoomSettings: (...args) => {
551+
methodDeprecationLogger.method('saveRoomSettings', '9.0.0', '/v1/rooms.saveRoomSettings');
550552
const userId = Meteor.userId();
551553
if (!userId) {
552554
throw new Meteor.Error('error-invalid-user', 'Invalid user', {

apps/meteor/app/cloud/server/methods.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { startRegisterWorkspace } from './functions/startRegisterWorkspace';
1212
import { syncWorkspace } from './functions/syncWorkspace';
1313
import { userLogout } from './functions/userLogout';
1414
import { hasPermissionAsync } from '../../authorization/server/functions/hasPermission';
15+
import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger';
1516

1617
declare module '@rocket.chat/ddp-client' {
1718
// eslint-disable-next-line @typescript-eslint/naming-convention
@@ -40,6 +41,7 @@ Meteor.methods<ServerMethods>({
4041
* Prefer using cloud.registrationStatus rest api.
4142
*/
4243
async 'cloud:checkRegisterStatus'() {
44+
methodDeprecationLogger.method('cloud:checkRegisterStatus', '9.0.0', []);
4345
const uid = Meteor.userId();
4446

4547
if (!uid) {
@@ -74,6 +76,7 @@ Meteor.methods<ServerMethods>({
7476
return Buffer.from(JSON.stringify(await buildWorkspaceRegistrationData(undefined))).toString('base64');
7577
},
7678
async 'cloud:registerWorkspace'() {
79+
methodDeprecationLogger.method('cloud:registerWorkspace', '9.0.0', []);
7780
const uid = Meteor.userId();
7881

7982
if (!uid) {
@@ -91,6 +94,7 @@ Meteor.methods<ServerMethods>({
9194
return startRegisterWorkspace();
9295
},
9396
async 'cloud:syncWorkspace'() {
97+
methodDeprecationLogger.method('cloud:syncWorkspace', '9.0.0', '/v1/cloud.syncWorkspace');
9498
const uid = Meteor.userId();
9599

96100
if (!uid) {
@@ -136,6 +140,7 @@ Meteor.methods<ServerMethods>({
136140
},
137141
// Currently unused but will link local account to Rocket.Chat Cloud account.
138142
async 'cloud:getOAuthAuthorizationUrl'() {
143+
methodDeprecationLogger.method('cloud:getOAuthAuthorizationUrl', '9.0.0', []);
139144
const uid = Meteor.userId();
140145
if (!uid) {
141146
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
@@ -152,6 +157,7 @@ Meteor.methods<ServerMethods>({
152157
return getOAuthAuthorizationUrl();
153158
},
154159
async 'cloud:finishOAuthAuthorization'(code, state) {
160+
methodDeprecationLogger.method('cloud:finishOAuthAuthorization', '9.0.0', []);
155161
check(code, String);
156162
check(state, String);
157163

@@ -172,6 +178,7 @@ Meteor.methods<ServerMethods>({
172178
return finishOAuthAuthorization(code, state);
173179
},
174180
async 'cloud:checkUserLoggedIn'() {
181+
methodDeprecationLogger.method('cloud:checkUserLoggedIn', '9.0.0', []);
175182
const uid = Meteor.userId();
176183
if (!uid) {
177184
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
@@ -188,6 +195,7 @@ Meteor.methods<ServerMethods>({
188195
return checkUserHasCloudLogin(uid);
189196
},
190197
async 'cloud:logout'() {
198+
methodDeprecationLogger.method('cloud:logout', '9.0.0', []);
191199
const uid = Meteor.userId();
192200
if (!uid) {
193201
throw new Meteor.Error('error-invalid-user', 'Invalid user', {

apps/meteor/app/crowd/server/methods.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Meteor } from 'meteor/meteor';
55
import { CROWD } from './crowd';
66
import { logger } from './logger';
77
import { hasPermissionAsync } from '../../authorization/server/functions/hasPermission';
8+
import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger';
89
import { settings } from '../../settings/server';
910

1011
declare module '@rocket.chat/ddp-client' {
@@ -17,6 +18,7 @@ declare module '@rocket.chat/ddp-client' {
1718

1819
Meteor.methods<ServerMethods>({
1920
async crowd_test_connection() {
21+
methodDeprecationLogger.method('crowd_test_connection', '9.0.0', []);
2022
const user = await Meteor.userAsync();
2123
if (!user) {
2224
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
@@ -51,6 +53,7 @@ Meteor.methods<ServerMethods>({
5153
}
5254
},
5355
async crowd_sync_users() {
56+
methodDeprecationLogger.method('crowd_sync_users', '9.0.0', []);
5457
const user = await Meteor.userAsync();
5558
if (settings.get('CROWD_Enable') !== true) {
5659
throw new Meteor.Error('crowd_disabled');

apps/meteor/app/discussion/server/methods/createDiscussion.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { attachMessage } from '../../../lib/server/functions/attachMessage';
1515
import { createRoom } from '../../../lib/server/functions/createRoom';
1616
import { sendMessage } from '../../../lib/server/functions/sendMessage';
1717
import { afterSaveMessageAsync } from '../../../lib/server/lib/afterSaveMessage';
18+
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
1819
import { settings } from '../../../settings/server';
1920

2021
const getParentRoom = async (rid: IRoom['_id']) => {
@@ -85,7 +86,7 @@ const create = async ({
8586
}
8687
if (prid) {
8788
const parentRoom = await getParentRoom(message.rid);
88-
if (!parentRoom || prid !== parentRoom._id) {
89+
if (prid !== parentRoom?._id) {
8990
throw new Meteor.Error('error-invalid-arguments', 'Root message room ID does not match parent room ID ', {
9091
method: 'DiscussionCreation',
9192
});
@@ -247,6 +248,7 @@ Meteor.methods<ServerMethods>({
247248
* @param {boolean} encrypted - if the discussion's e2e encryption should be enabled.
248249
*/
249250
async createDiscussion({ prid, pmid, t_name: discussionName, reply, users, encrypted }: CreateDiscussionProperties) {
251+
methodDeprecationLogger.method('createDiscussion', '9.0.0', '/v1/rooms.createDiscussion');
250252
check(prid, Match.Maybe(String));
251253
check(pmid, Match.Maybe(String));
252254
check(reply, Match.Maybe(String));

apps/meteor/app/e2e/server/methods/fetchMyKeys.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client';
22
import { Users } from '@rocket.chat/models';
33
import { Meteor } from 'meteor/meteor';
44

5+
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
6+
57
declare module '@rocket.chat/ddp-client' {
68
// eslint-disable-next-line @typescript-eslint/naming-convention
79
interface ServerMethods {
@@ -11,6 +13,7 @@ declare module '@rocket.chat/ddp-client' {
1113

1214
Meteor.methods<ServerMethods>({
1315
async 'e2e.fetchMyKeys'() {
16+
methodDeprecationLogger.method('e2e.fetchMyKeys', '9.0.0', '/v1/e2e.fetchMyKeys');
1417
const userId = Meteor.userId();
1518
if (!userId) {
1619
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'e2e.fetchMyKeys' });

0 commit comments

Comments
 (0)