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/mail-messages/server/methods/sendMail.js

29 lines
745 B

import { Meteor } from 'meteor/meteor';
import { Mailer } from '../lib/Mailer';
import { hasRole } from '../../../authorization';
Meteor.methods({
'Mailer.sendMail'(from, subject, body, dryrun, query) {
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'Mailer.sendMail',
});
}
if (hasRole(userId, 'admin') !== true) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'Mailer.sendMail',
});
}
return Mailer.sendMail(from, subject, body, dryrun, query);
},
});
// Limit setting username once per minute
// DDPRateLimiter.addRule
// type: 'method'
// name: 'Mailer.sendMail'
// connectionId: -> return true
// , 1, 60000