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

Merge pull request #120 from RocketChat/mentions

Mentions
parents 0d989643 a42b1b99
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
@primary-background-color: #04436a; @primary-background-color: #04436a;
@secondary-background-color: #F4F4F4; @secondary-background-color: #F4F4F4;
@tertiary-background-color: #EAEAEA; @tertiary-background-color: #EAEAEA;
@link-font-color: #008CE3;
@primary-font-color: #444444; @primary-font-color: #444444;
@secondary-font-color: #7f7f7f; @secondary-font-color: #7f7f7f;
@tertiary-font-color: rgba(255, 255, 255, 0.6); @tertiary-font-color: rgba(255, 255, 255, 0.6);
...@@ -1643,10 +1644,11 @@ a.github-fork { ...@@ -1643,10 +1644,11 @@ a.github-fork {
} }
> div { > div {
a { a {
color: @primary-background-color; color: @link-font-color;
font-weight: 500; font-weight: 400;
&:hover { &:hover {
color: darken(@primary-background-color, 10%); color: darken(@link-font-color, 10%);
text-decoration: underline;
} }
} }
ul{ ul{
......
...@@ -12,8 +12,20 @@ Template.chatMessageDashboard.helpers ...@@ -12,8 +12,20 @@ Template.chatMessageDashboard.helpers
isEditing: -> isEditing: ->
return this._id is Session.get('editingMessageId') return this._id is Session.get('editingMessageId')
autolinker: (msg) -> autolinkerAndMentions: ->
return Autolinker.link(_.stripTags(msg), { stripPrefix: false }) msg = Autolinker.link(_.stripTags(this.msg), { stripPrefix: false, twitter: false })
if not this.mentions? or this.mentions.length is 0
return msg
mentions = _.map this.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>"
return msg
message: -> message: ->
if this.by if this.by
...@@ -64,6 +76,11 @@ Template.chatMessageDashboard.events ...@@ -64,6 +76,11 @@ Template.chatMessageDashboard.events
Meteor.defer -> Meteor.defer ->
$('.input-message-editing').select() $('.input-message-editing').select()
# TODO open flextab with user info
# 'click .mention-link': ->
# Session.set('flexOpened', true)
# Session.set('showUserInfo', $(e.currentTarget).data('username'))
Template.chatMessageDashboard.onRendered -> Template.chatMessageDashboard.onRendered ->
chatMessages = $('.messages-box .wrapper') chatMessages = $('.messages-box .wrapper')
message = $(this.firstNode) message = $(this.firstNode)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</div> </div>
{{else}} {{else}}
<div> <div>
{{#markdown}}{{#emojione}}{{autolinker message}}{{/emojione}}{{/markdown}} {{#markdown}}{{#emojione}}{{autolinkerAndMentions message}}{{/emojione}}{{/markdown}}
</div> </div>
{{/if}} {{/if}}
{{/if}} {{/if}}
......
...@@ -28,10 +28,28 @@ Meteor.methods ...@@ -28,10 +28,28 @@ Meteor.methods
messageFilter = { rid: rid, uid: Meteor.userId(), t: 't' } messageFilter = { rid: rid, uid: Meteor.userId(), t: 't' }
activityFilter = { rid: rid, uid: { $ne: Meteor.userId() } } activityFilter = { rid: rid, uid: { $ne: Meteor.userId() } }
mentions = []
msg.message.replace /(?:^|\s|\n)(?:@)([A-Za-z0-9-_.]+)/g, (match, mention) ->
mentions.push mention
mentions = _.unique mentions
mentions = mentions.filter (mention) ->
return Meteor.users.findOne({username: mention}, {fields: {_id: 1}})?
mentions = mentions.map (mention) ->
return {
username: mention
}
if mentions.length is 0
mentions = undefined
ChatMessage.upsert messageFilter, ChatMessage.upsert messageFilter,
$set: $set:
ts: now ts: now
msg: msg.message msg: msg.message
mentions: mentions
$unset: $unset:
t: 1 t: 1
expireAt: 1 expireAt: 1
......
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