Skip to content
Snippets Groups Projects
Commit 25e017da authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Parse mentions to channels and add link to room

parent 574cb845
No related branches found
No related tags found
No related merge requests found
...@@ -456,6 +456,13 @@ Template.room.events ...@@ -456,6 +456,13 @@ Template.room.events
# $('.input-message-editing').select() # $('.input-message-editing').select()
"click .mention-link": (e) -> "click .mention-link": (e) ->
channel = $(e.currentTarget).data('channel')
if channel?
channelObj = ChatSubscription.findOne name: channel
if channelObj?
FlowRouter.go 'room', {_id: channelObj.rid}
return
Session.set('flexOpened', true) Session.set('flexOpened', true)
Session.set('showUserInfo', $(e.currentTarget).data('username')) Session.set('showUserInfo', $(e.currentTarget).data('username'))
......
...@@ -11,6 +11,7 @@ class MentionsClient ...@@ -11,6 +11,7 @@ class MentionsClient
mentions = [] mentions = []
message.msg.replace /(?:^|\s|\n)(?:@)([A-Za-z0-9-_.]+)/g, (match, mention) -> message.msg.replace /(?:^|\s|\n)(?:@)([A-Za-z0-9-_.]+)/g, (match, mention) ->
mentions.push mention mentions.push mention
if mentions.length isnt 0 if mentions.length isnt 0
mentions = _.unique mentions mentions = _.unique mentions
mentions = mentions.join('|') mentions = mentions.join('|')
...@@ -24,6 +25,17 @@ class MentionsClient ...@@ -24,6 +25,17 @@ class MentionsClient
return match.replace mention, "<a href=\"\" class=\"mention-link\" data-username=\"#{username}\">#{mention}</a>" return match.replace mention, "<a href=\"\" class=\"mention-link\" data-username=\"#{username}\">#{mention}</a>"
channels = []
message.msg.replace /(?:^|\s|\n)(?:#)([A-Za-z0-9-_.]+)/g, (match, mention) ->
channels.push mention
if channels.length isnt 0
channels = _.unique channels
channels = channels.join('|')
msg = msg.replace new RegExp("(?:^|\\s)(#(#{channels}))(?:\\s|$)", 'g'), (match, mention, channel) ->
return match.replace mention, "<a href=\"\" class=\"mention-link\" data-channel=\"#{channel}\">#{mention}</a>"
message.html = msg message.html = msg
return message return message
......
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