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/app/integrations/server/methods/outgoing/addOutgoingIntegration.js

29 lines
1013 B

import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../../../../authorization/server';
import { Users } from '../../../../models/server';
import { Integrations } from '../../../../models/server/raw';
import { integrations } from '../../../lib/rocketchat';
Meteor.methods({
async addOutgoingIntegration(integration) {
if (
!hasPermission(this.userId, 'manage-outgoing-integrations') &&
!hasPermission(this.userId, 'manage-own-outgoing-integrations') &&
!hasPermission(this.userId, 'manage-outgoing-integrations', 'bot') &&
!hasPermission(this.userId, 'manage-own-outgoing-integrations', 'bot')
) {
throw new Meteor.Error('not_authorized');
}
integration = integrations.validateOutgoing(integration, this.userId);
integration._createdAt = new Date();
integration._createdBy = Users.findOne(this.userId, { fields: { username: 1 } });
const result = await Integrations.insertOne(integration);
integration._id = result.insertedId;
return integration;
},
});