Skip to content
Snippets Groups Projects
Commit bf639ff5 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Improve report abuse to pass the message id instead of message object

Closes #6038
parent 790c6193
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ const mobileMessageMenu = {
return false;
}
Meteor.call('reportMessage', message, inputValue);
Meteor.call('reportMessage', message._id, inputValue);
swal({
title: TAPi18n.__('Report_sent'),
......
Meteor.methods({
reportMessage(message, description) {
check(message, Object);
reportMessage(messageId, description) {
check(messageId, String);
check(description, String);
if (!Meteor.userId()) {
......@@ -15,6 +15,13 @@ Meteor.methods({
});
}
const message = RocketChat.models.Messages.findOneById(messageId);
if (!message) {
throw new Meteor.Error('error-invalid-message_id', 'Invalid message id', {
method: 'reportMessage'
});
}
return RocketChat.models.Reports.createWithMessageDescriptionAndUserId(message, description, Meteor.userId());
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment