diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-11-11 15:12:51 +0200 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-11-19 01:25:27 +0200 |
commit | fd2c0fe446c7f761b845c91307ef8110d869e8e8 (patch) | |
tree | 1a2b6c53f6a4c5c24fcb57adad7a2cd115e72623 /app/services/notes/create_service.rb | |
parent | 61867abeeccf9e6f65ba38c365d8bdf6b61387f4 (diff) | |
download | gitlab-ce-fd2c0fe446c7f761b845c91307ef8110d869e8e8.tar.gz |
award emoji
Diffstat (limited to 'app/services/notes/create_service.rb')
-rw-r--r-- | app/services/notes/create_service.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb index 2001dc89c33..f448f61cc86 100644 --- a/app/services/notes/create_service.rb +++ b/app/services/notes/create_service.rb @@ -5,11 +5,16 @@ module Notes note.author = current_user note.system = false + if contains_emoji_only?(params[:note]) + note.is_award = true + note.note = emoji_name(params[:note]) + end + if note.save notification_service.new_note(note) - # Skip system notes, like status changes and cross-references. - unless note.system + # Skip system notes, like status changes and cross-references and awards + unless note.system || note.is_award event_service.leave_note(note, note.author) note.create_cross_references! execute_hooks(note) @@ -28,5 +33,13 @@ module Notes note.project.execute_hooks(note_data, :note_hooks) note.project.execute_services(note_data, :note_hooks) end + + def contains_emoji_only?(note) + note =~ /^:[-_+[:alnum:]]*:\s?/ + end + + def emoji_name(note) + note.match(/\A:([-_+[:alnum:]]*):\s?/)[1] + end end end |