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/packages/rocketchat-lib/client/methods/sendMessage.js

22 lines
706 B

Meteor.methods({
sendMessage(message) {
if (!Meteor.userId() || _.trim(message.msg) === '') {
return false;
}
const user = Meteor.user();
message.ts = isNaN(TimeSync.serverOffset()) ? new Date() : new Date(Date.now() + TimeSync.serverOffset());
message.u = {
_id: Meteor.userId(),
username: user.username
};
if (RocketChat.settings.get('UI_Use_Real_Name')) {
message.u.name = user.name;
}
message.temp = true;
message = RocketChat.callbacks.run('beforeSaveMessage', message);
RocketChat.promises.run('onClientMessageReceived', message).then(function(message) {
ChatMessage.insert(message);
return RocketChat.callbacks.run('afterSaveMessage', message);
});
}
});