Changing edit message logic based on Message_AllowEditing_BlockEditInMinutes value

pull/833/head
George Secrieru 10 years ago
parent 31440e16ed
commit 3f0a635159
  1. 10
      client/lib/chatMessages.coffee
  2. 13
      client/methods/updateMessage.coffee
  3. 11
      client/views/app/message.coffee
  4. 11
      packages/rocketchat-lib/client/MessageAction.coffee
  5. 11
      server/methods/updateMessage.coffee

@ -49,10 +49,12 @@ class @ChatMessages
return unless hasPermission or (editAllowed and editOwn)
return if element.classList.contains("system")
msgTs = moment(message.ts) if message.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
if currentTsDiff > RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
return
blockEditInMinutes = RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
if blockEditInMinutes? and blockEditInMinutes isnt 0
msgTs = moment(message.ts) if message.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
if currentTsDiff > blockEditInMinutes
return
this.clearEditing()
this.input.value = message.msg

@ -13,12 +13,13 @@ Meteor.methods
toastr.error t('Message_editing_not_allowed')
throw new Meteor.Error 'message-editing-not-allowed', t('Message_editing_not_allowed')
msgTs = moment(originalMessage.ts) if originalMessage.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
if currentTsDiff > RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
toastr.error t('Message_editing_blocked')
throw new Meteor.Error 'message-editing-blocked'
blockEditInMinutes = RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
if blockEditInMinutes? and blockEditInMinutes isnt 0
msgTs = moment(originalMessage.ts) if originalMessage.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
if currentTsDiff > blockEditInMinutes
toastr.error t('Message_editing_blocked')
throw new Meteor.Error 'message-editing-blocked'
Tracker.nonreactive ->

@ -48,10 +48,13 @@ Template.message.helpers
return unless hasPermission or (isEditAllowed and editOwn)
msgTs = moment(this.ts) if this.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
return currentTsDiff < RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
blockEditInMinutes = RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
if blockEditInMinutes? and blockEditInMinutes isnt 0
msgTs = moment(this.ts) if this.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
return currentTsDiff < blockEditInMinutes
else
return true
canDelete: ->
if RocketChat.authz.hasAtLeastOnePermission('delete-message', this.rid )

@ -74,10 +74,13 @@ Meteor.startup ->
return unless hasPermission or (isEditAllowed and editOwn)
msgTs = moment(message.ts) if message.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
return currentTsDiff < RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
blockEditInMinutes = RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
if blockEditInMinutes? and blockEditInMinutes isnt 0
msgTs = moment(message.ts) if message.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
return currentTsDiff < blockEditInMinutes
else
return true
order: 1
RocketChat.MessageAction.addButton

@ -12,11 +12,12 @@ Meteor.methods
unless hasPermission or (editAllowed and editOwn)
throw new Meteor.Error 'message-editing-not-allowed', "[methods] updateMessage -> Message editing not allowed"
msgTs = moment(originalMessage.ts) if originalMessage.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
if currentTsDiff > RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
throw new Meteor.Error 'message-editing-blocked', "[methods] updateMessage -> Message editing blocked"
blockEditInMinutes = RocketChat.settings.get 'Message_AllowEditing_BlockEditInMinutes'
if blockEditInMinutes? and blockEditInMinutes isnt 0
msgTs = moment(originalMessage.ts) if originalMessage.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
if currentTsDiff > blockEditInMinutes
throw new Meteor.Error 'message-editing-blocked'
console.log '[methods] updateMessage -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments

Loading…
Cancel
Save