The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/slackbridge/server/removeChannelLinks.ts

41 lines
1.2 KiB

import { Meteor } from 'meteor/meteor';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { Rooms } from '@rocket.chat/models';
import { hasPermissionAsync } from '../../authorization/server/functions/hasPermission';
import { settings } from '../../settings/server';
declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
removeSlackBridgeChannelLinks(): { message: string; params: unknown[] };
}
}
Meteor.methods<ServerMethods>({
async removeSlackBridgeChannelLinks() {
const user = await Meteor.userAsync();
if (!user) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'removeSlackBridgeChannelLinks',
});
}
if (!(await hasPermissionAsync(user._id, '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: [],
};
},
});