import type { ServerMethods } from '@rocket.chat/ddp-client'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; import { methodDeprecationLogger } from '../../lib/deprecationWarningLogger'; import { insertOrUpdateSound } from '../../lib/media/custom-sounds/lib/insertOrUpdateSound'; export type ICustomSoundData = { _id?: string; name: string; extension: string; previousName?: string; previousSound?: { extension?: string; }; previousExtension?: string; newFile?: boolean; random?: number; }; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention interface ServerMethods { insertOrUpdateSound(soundData: ICustomSoundData): Promise; } } 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'); } if (soundData._id) { check(soundData._id, String); } return insertOrUpdateSound(soundData); }, });