Skip to content
Snippets Groups Projects
Unverified Commit 5dbf4eb4 authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Check timestamp before notifying users

parent 1bc66053
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,10 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
return message;
}
if (message.ts && (moment(message.ts).subtract(5, 'seconds').isBefore(new Date) || moment(message.ts).isAfter(moment().add(5, 'seconds')))) {
return message;
}
/**
* Chechs if a messages contains a user highlight
*
......
......@@ -4,6 +4,10 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
return message;
}
if (message.ts && (moment(message.ts).subtract(5, 'seconds').isBefore(new Date) || moment(message.ts).isAfter(moment().add(5, 'seconds')))) {
return message;
}
var emailSubject, usersToSendEmail = {};
var directMessage = room.t === 'd';
......
Meteor.methods
sendMessage: (message) ->
if message.ts and (moment(message.ts).subtract(5, 'seconds').isBefore(new Date) or moment(message.ts).isAfter(moment().add(5, 'seconds')))
throw new Meteor.Error('error-message-ts-out-of-sync', 'Message timestamp is out of sync', { method: 'sendMessage', message_ts: message.ts, server_ts: new Date().getTime() })
if message.msg?.length > RocketChat.settings.get('Message_MaxAllowedSize')
throw new Meteor.Error('error-message-size-exceeded', 'Message size exceeds Message_MaxAllowedSize', { method: 'sendMessage' })
......
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