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/server/methods/setAvatarFromService.js

37 lines
968 B

import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
import { settings } from 'meteor/rocketchat:settings';
import { setUserAvatar } from 'meteor/rocketchat:lib';
Meteor.methods({
setAvatarFromService(dataURI, contentType, service) {
check(dataURI, String);
check(contentType, Match.Optional(String));
check(service, Match.Optional(String));
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'setAvatarFromService',
});
}
if (!settings.get('Accounts_AllowUserAvatarChange')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'setAvatarFromService',
});
}
const user = Meteor.user();
return setUserAvatar(user, dataURI, contentType, service);
},
});
DDPRateLimiter.addRule({
type: 'method',
name: 'setAvatarFromService',
userId() {
return true;
},
}, 1, 5000);