Skip to content
Snippets Groups Projects
Commit e0192b7f authored by Guilherme Gazzo's avatar Guilherme Gazzo
Browse files

fix review

parent 178fca66
No related branches found
No related tags found
No related merge requests found
...@@ -32,16 +32,16 @@ Meteor.methods({ ...@@ -32,16 +32,16 @@ Meteor.methods({
action: 'Delete_message' action: 'Delete_message'
}); });
} }
let msgTs;
let currentTsDiff;
const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes'); const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
if ((blockDeleteInMinutes != null) && blockDeleteInMinutes !== 0) { if (blockDeleteInMinutes != null && blockDeleteInMinutes !== 0) {
if (originalMessage.ts != null) { if (originalMessage.ts == null) {
msgTs = moment(originalMessage.ts); return;
} }
if (msgTs != null) { const msgTs = moment(originalMessage.ts);
currentTsDiff = moment().diff(msgTs, 'minutes'); if (msgTs == null) {
return;
} }
const currentTsDiff = moment().diff(msgTs, 'minutes');
if (currentTsDiff > blockDeleteInMinutes) { if (currentTsDiff > blockDeleteInMinutes) {
throw new Meteor.Error('error-message-deleting-blocked', 'Message deleting is blocked', { throw new Meteor.Error('error-message-deleting-blocked', 'Message deleting is blocked', {
method: 'deleteMessage' method: 'deleteMessage'
......
...@@ -20,6 +20,6 @@ Meteor.methods({ ...@@ -20,6 +20,6 @@ Meteor.methods({
}); });
} }
const cursor = RocketChat.models[model][method].apply(RocketChat.models[model], args); const cursor = RocketChat.models[model][method].apply(RocketChat.models[model], args);
return cursor && cursor.fetch && cursor.fetch(); return cursor && cursor.fetch ? cursor.fetch() : cursor;
} }
}); });
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