Moved hooks to beforeSaveMessage

pull/185/head^2
Marcelo Schmidt 11 years ago
parent 46452ea27c
commit e6ecfbe613
  1. 7
      client/lib/collections.coffee
  2. 6
      client/views/app/chatMessageDashboard.coffee
  3. 2
      client/views/app/chatMessageDashboard.html
  4. 2
      packages/rocketchat-autolinker/autolinker.coffee
  5. 2
      packages/rocketchat-highlight/highlight.coffee
  6. 2
      packages/rocketchat-markdown/markdown.coffee
  7. 2
      packages/rocketchat-me/me.coffee
  8. 2
      packages/rocketchat-mentions/client.coffee
  9. 28
      server/methods/sendMessage.coffee

@ -3,12 +3,7 @@
@ChatRoom = new Meteor.Collection 'data.ChatRoom'
@ChatSubscription = new Meteor.Collection 'data.ChatSubscription'
@ChatMessage = new Meteor.Collection 'data.ChatMessage',
transform: (message) ->
message.html = message.msg
message = RocketChat.callbacks.run 'renderMessage', message
# console.log 'transform'
return message
@ChatMessage = new Meteor.Collection 'data.ChatMessage'
Meteor.startup ->
ChatMessage.find().observe

@ -14,12 +14,6 @@ Template.chatMessageDashboard.helpers
isEditing: ->
return this._id is Session.get('editingMessageId')
preProcessingMessage: ->
this.html = this.msg
message = RocketChat.callbacks.run 'renderMessage', this
return message.html
message: ->
switch this.t
when 'r' then t('chatMessageDashboard.Room_name_changed', { room_name: this.msg, user_by: Session.get('user_' + this.u._id + '_name') }) + '.'

@ -42,7 +42,7 @@
</span>
{{/if}}
<div>
{{{preProcessingMessage}}}
{{#emojione}}{{html}}{{/emojione}}
</div>
{{/if}}
{{/if}}

@ -10,4 +10,4 @@ class AutoLinker
return message
RocketChat.callbacks.add 'renderMessage', AutoLinker
RocketChat.callbacks.add 'beforeSaveMessage', AutoLinker

@ -35,4 +35,4 @@ class Highlight
return message
RocketChat.callbacks.add 'renderMessage', Highlight, RocketChat.callbacks.priority.HIGH
RocketChat.callbacks.add 'beforeSaveMessage', Highlight, RocketChat.callbacks.priority.HIGH

@ -15,4 +15,4 @@ class Markdown
message.html = msg
return message
RocketChat.callbacks.add 'renderMessage', Markdown, RocketChat.callbacks.priority.LOW
RocketChat.callbacks.add 'beforeSaveMessage', Markdown, RocketChat.callbacks.priority.LOW

@ -11,4 +11,4 @@ class Me
message.html = '_' + message.html.replace('/me ','') + '_'
return message
RocketChat.callbacks.add 'renderMessage', Me
RocketChat.callbacks.add 'beforeSaveMessage', Me

@ -20,4 +20,4 @@ class MentionsClient
message.html = msg
return message
RocketChat.callbacks.add 'renderMessage', MentionsClient
RocketChat.callbacks.add 'beforeSaveMessage', MentionsClient

@ -14,35 +14,7 @@ Meteor.methods
message.ts = new Date()
message.html = message.msg
# if _.trim(message.html) isnt ''
# message.html = _.escapeHTML message.html
# message.html = message.html.replace /\n/g, '<br/>'
# Process links in message
# msg = Autolinker.link(msg, { stripPrefix: false, twitter: false })
# Process MD like for strong, italic and strike
# msg = msg.replace(/\*([^*]+)\*/g, '<strong>$1</strong>')
# msg = msg.replace(/\_([^_]+)\_/g, '<i>$1</i>')
# msg = msg.replace(/\~([^_]+)\~/g, '<strike>$1</strike>')
# Highlight mentions
# if not message.mentions? or message.mentions.length is 0
# mentions = _.map message.mentions, (mention) ->
# return mention.username or mention
# mentions = mentions.join('|')
# msg = msg.replace new RegExp("(?:^|\\s)(@(#{mentions}))(?:\\s|$)", 'g'), (match, mention, username) ->
# return match.replace mention, "<a href=\"\" class=\"mention-link\" data-username=\"#{username}\">#{mention}</a>"
# message = RocketChat.callbacks.run 'beforeSaveMessage', message
if _.trim(message.html) isnt ''
message.html = _.escapeHTML message.html
message = RocketChat.callbacks.run 'beforeSaveMessage', message
message.html = message.html.replace /\n/g, '<br/>'
# console.log "message", message
###
Defer other updated as their return is not interesting to the user

Loading…
Cancel
Save