Skip to content

Commit

Permalink
[FIX] Not showing edit message button when blocking edit after N minu…
Browse files Browse the repository at this point in the history
…tes (#25724)

Co-authored-by: Diego Sampaio <chinello@gmail.com>
  • Loading branch information
matthias4217 and sampaiodiego committed Jul 20, 2022
1 parent 94fcdb3 commit ddfba35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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');
}
return !!currentTsDiff && currentTsDiff < blockEditInMinutes;
return (!!currentTsDiff || currentTsDiff === 0) && currentTsDiff < blockEditInMinutes;
}
return true;
},
Expand Down

0 comments on commit ddfba35

Please sign in to comment.