Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/meteor/app/lib/server/methods/updateMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ Meteor.methods({
let currentTsDiff;
let msgTs;

if (Match.test(originalMessage.ts, Number)) {
if (originalMessage.ts instanceof Date || Match.test(originalMessage.ts, Number)) {
msgTs = moment(originalMessage.ts);
}
if (msgTs) {
currentTsDiff = moment().diff(msgTs, 'minutes');
}
if (currentTsDiff > blockEditInMinutes) {
if (currentTsDiff >= blockEditInMinutes) {
throw new Meteor.Error('error-message-editing-blocked', 'Message editing is blocked', {
method: 'updateMessage',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Meteor.startup(async function () {
if (msgTs != null) {
currentTsDiff = moment().diff(msgTs, 'minutes');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the current change, I could have changed currentTsDiff = moment().diff(msgTs, 'minutes'); (which returns an Integer) to currentTsDiff = moment().diff(msgTs, 'minutes', true);, which returns a precise float, meaning currentTsDiff would never equal 0.

I don't know if you have any preference ?

}
return !!currentTsDiff && currentTsDiff < blockEditInMinutes;
return (!!currentTsDiff || currentTsDiff === 0) && currentTsDiff < blockEditInMinutes;
}
return true;
},
Expand Down