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/client/methods/deleteMessage.js

30 lines
623 B

import { Meteor } from 'meteor/meteor';
import { ChatMessage } from '../../app/models/client';
import { canDeleteMessage } from '../lib/utils/canDeleteMessage';
Meteor.methods({
deleteMessage(msg) {
if (!Meteor.userId()) {
return false;
}
// We're now only passed in the `_id` property to lower the amount of data sent to the server
const message = ChatMessage.findOne({ _id: msg._id });
if (
!canDeleteMessage({
rid: message.rid,
ts: message.ts,
uid: message.u._id,
})
) {
return false;
}
ChatMessage.remove({
'_id': message._id,
'u._id': Meteor.userId(),
});
},
});