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/message-star/client/starMessage.js

35 lines
912 B

import { Meteor } from 'meteor/meteor';
import toastr from 'toastr';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { settings } from '../../settings';
import { ChatMessage, Subscriptions } from '../../models';
Meteor.methods({
starMessage(message) {
if (!Meteor.userId()) {
toastr.error(TAPi18n.__('error-starring-message'));
return false;
}
if (Subscriptions.findOne({ rid: message.rid }) == null) {
toastr.error(TAPi18n.__('error-starring-message'));
return false;
}
if (!settings.get('Message_AllowStarring')) {
toastr.error(TAPi18n.__('error-starring-message'));
return false;
}
if (message.starred) {
toastr.success(TAPi18n.__('Message_has_been_starred'));
} else {
toastr.success(TAPi18n.__('Message_has_been_unstarred'));
}
return ChatMessage.update({
_id: message._id,
}, {
$set: {
starred: !!message.starred,
},
});
},
});