Skip to content
Snippets Groups Projects
Commit 0b1d83a4 authored by Gabriel Engel's avatar Gabriel Engel Committed by GitHub
Browse files

Merge pull request #6039 from RocketChat/improvements/report-abuse

Improve report abuse to pass the message id instead of message object
parents 0ac50e44 bf639ff5
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