Commit 22d87b74 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Support award-emoji notes only when it a comment for an issue

parent 9cf67f72
...@@ -5,9 +5,9 @@ module Notes ...@@ -5,9 +5,9 @@ module Notes
note.author = current_user note.author = current_user
note.system = false note.system = false
if contains_emoji_only?(params[:note]) if award_emoji_note?
note.is_award = true note.is_award = true
note.note = emoji_name(params[:note]) note.note = emoji_name
end end
if note.save if note.save
...@@ -34,12 +34,23 @@ module Notes ...@@ -34,12 +34,23 @@ module Notes
note.project.execute_services(note_data, :note_hooks) note.project.execute_services(note_data, :note_hooks)
end end
def contains_emoji_only?(note) private
note =~ /\A:[-_+[:alnum:]]*:\s?\z/
def award_emoji_note?
# We support award-emojis only in issue discussion
issue_comment? && contains_emoji_only?
end
def contains_emoji_only?
params[:note] =~ /\A:[-_+[:alnum:]]*:\s?\z/
end
def issue_comment?
params[:noteable_type] == 'Issue'
end end
def emoji_name(note) def emoji_name
note.match(/\A:([-_+[:alnum:]]*):\s?/)[1] params[:note].match(/\A:([-_+[:alnum:]]*):\s?/)[1]
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment