From ea5c513c7c234da87e1b1293734e5a1eaf645e21 Mon Sep 17 00:00:00 2001 From: Nazareno Bucciarelli Date: Wed, 18 Mar 2026 21:56:42 -0300 Subject: [PATCH 1/3] add deprecation warning to custom sound meteor methods, modify methodDeprecationLogger --- .../server/methods/insertOrUpdateSound.ts | 2 ++ .../server/methods/uploadCustomSound.ts | 2 ++ .../app/lib/server/lib/deprecationWarningLogger.ts | 14 ++++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts b/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts index 1b922c6b162ed..a3c57df494f87 100644 --- a/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts +++ b/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts @@ -5,6 +5,7 @@ import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; +import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds'; export type ICustomSoundData = { @@ -29,6 +30,7 @@ declare module '@rocket.chat/ddp-client' { Meteor.methods({ async insertOrUpdateSound(soundData) { + methodDeprecationLogger.method('insertOrUpdateSound', '9.0.0', ['/v1/custom-sounds.create', '/v1/custom-sounds.update']); if (!this.userId || !(await hasPermissionAsync(this.userId, 'manage-sounds'))) { throw new Meteor.Error('not_authorized'); } diff --git a/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts b/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts index 64286bb71d86a..76a1944fc11e7 100644 --- a/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts +++ b/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts @@ -6,6 +6,7 @@ import { Meteor } from 'meteor/meteor'; import type { ICustomSoundData } from './insertOrUpdateSound'; import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; import { RocketChatFile } from '../../../file/server'; +import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds'; declare module '@rocket.chat/ddp-client' { @@ -17,6 +18,7 @@ declare module '@rocket.chat/ddp-client' { Meteor.methods({ async uploadCustomSound(binaryContent, contentType, soundData) { + methodDeprecationLogger.method('uploadCustomSound', '9.0.0', ['/v1/custom-sounds.create', '/v1/custom-sounds.update']); if (!this.userId || !(await hasPermissionAsync(this.userId, 'manage-sounds'))) { throw new Meteor.Error('not_authorized'); } diff --git a/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts b/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts index ee74d472ff05c..5e4dab8c4f22e 100644 --- a/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts +++ b/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts @@ -100,14 +100,16 @@ export const apiDeprecationLogger = ((logger) => { }; })(deprecationLogger.section('API')); +type DeprecationPath = T extends `/${string}` ? (T extends PathPattern ? T : never) : string; + +type DeprecationInfo = DeprecationPath | Array>; + export const methodDeprecationLogger = ((logger) => { return { - method: ( - method: string, - version: DeprecationLoggerNextPlannedVersion, - info: T extends `/${string}` ? (T extends PathPattern ? T : never) : string, - ) => { - const replacement = typeof info === 'string' ? info : `Use the ${info} endpoint instead`; + method: (method: string, version: DeprecationLoggerNextPlannedVersion, info: DeprecationInfo) => { + const infoArray = Array.isArray(info) ? info : [info]; + const paths = infoArray.map((p) => (typeof p === 'string' && p.startsWith('/') ? `"${p}"` : p)).join(' or '); + const replacement = infoArray.length > 0 ? `Use the ${paths} endpoint${infoArray.length > 1 ? 's' : ''} instead` : ''; const message = `The method "${method}" is deprecated and will be removed on version ${version}${replacement ? ` (${replacement})` : ''}`; if (process.env.TEST_MODE === 'true') { throw new Error(message); From ec17b326afccb6e9f9b6fcab9658ac1d19dd57f5 Mon Sep 17 00:00:00 2001 From: Nazareno Bucciarelli Date: Thu, 26 Mar 2026 14:36:21 -0300 Subject: [PATCH 2/3] add todos --- .../app/custom-sounds/server/methods/insertOrUpdateSound.ts | 1 + .../meteor/app/custom-sounds/server/methods/uploadCustomSound.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts b/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts index a3c57df494f87..769705cfdaabc 100644 --- a/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts +++ b/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts @@ -28,6 +28,7 @@ declare module '@rocket.chat/ddp-client' { } } +// TODO remove custom-sounds Meteor methods on 9.0.0 Meteor.methods({ async insertOrUpdateSound(soundData) { methodDeprecationLogger.method('insertOrUpdateSound', '9.0.0', ['/v1/custom-sounds.create', '/v1/custom-sounds.update']); diff --git a/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts b/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts index 76a1944fc11e7..ad398722a7a1b 100644 --- a/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts +++ b/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts @@ -16,6 +16,7 @@ declare module '@rocket.chat/ddp-client' { } } +// TODO remove custom-sounds Meteor methods on 9.0.0 Meteor.methods({ async uploadCustomSound(binaryContent, contentType, soundData) { methodDeprecationLogger.method('uploadCustomSound', '9.0.0', ['/v1/custom-sounds.create', '/v1/custom-sounds.update']); From 0c3e0fa906acdc50949182af574f57deda014231 Mon Sep 17 00:00:00 2001 From: Nazareno Bucciarelli Date: Fri, 27 Mar 2026 16:43:12 -0300 Subject: [PATCH 3/3] add changeset --- .changeset/healthy-news-shout.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/healthy-news-shout.md diff --git a/.changeset/healthy-news-shout.md b/.changeset/healthy-news-shout.md new file mode 100644 index 0000000000000..cb73f5a9a66e2 --- /dev/null +++ b/.changeset/healthy-news-shout.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Deprecates `insertOrUpdateSound` and `uploadCustomSound` Meteor methods