import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Rooms } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; import { settings } from '../../settings'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention interface ServerMethods { removeSlackBridgeChannelLinks(): { message: string; params: unknown[] }; } } Meteor.methods({ async removeSlackBridgeChannelLinks() { const user = await Meteor.userAsync(); if (!user) { throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'removeSlackBridgeChannelLinks', }); } if (!(await hasPermissionAsync(user, 'remove-slackbridge-links'))) { throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'removeSlackBridgeChannelLinks', }); } if (settings.get('SlackBridge_Enabled') !== true) { throw new Meteor.Error('SlackBridge_disabled'); } await Rooms.unsetAllImportIds(); return { message: 'Slackbridge_channel_links_removed_successfully', params: [], }; }, });