Merge branch 'emoji_aliases' into 'master'
Emoji aliases problem Fixes #3850 See merge request !2064
This commit is contained in:
commit
2029be038b
6 changed files with 55 additions and 3 deletions
|
@ -43,6 +43,7 @@ v 8.3.0 (unreleased)
|
|||
- Prevent possible XSS attack with award-emoji
|
||||
- Upgraded Sidekiq to 4.x
|
||||
- Accept COPYING,COPYING.lesser, and licence as license file (Zeger-Jan van de Weg)
|
||||
- Fix emoji aliases problem
|
||||
|
||||
v 8.2.3
|
||||
- Fix application settings cache not expiring after changes (Stan Hu)
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
class @AwardsHandler
|
||||
constructor: (@post_emoji_url, @noteable_type, @noteable_id) ->
|
||||
constructor: (@post_emoji_url, @noteable_type, @noteable_id, @aliases) ->
|
||||
|
||||
addAward: (emoji) ->
|
||||
emoji = @normilizeEmojiName(emoji)
|
||||
@postEmoji emoji, =>
|
||||
@addAwardToEmojiBar(emoji)
|
||||
|
||||
addAwardToEmojiBar: (emoji, custom_path = '') ->
|
||||
emoji = @normilizeEmojiName(emoji)
|
||||
if @exist(emoji)
|
||||
if @isActive(emoji)
|
||||
@decrementCounter(emoji)
|
||||
|
@ -94,3 +96,6 @@ class @AwardsHandler
|
|||
$('body, html').animate({
|
||||
scrollTop: $('.awards').offset().top - 80
|
||||
}, 200)
|
||||
|
||||
normilizeEmojiName: (emoji) ->
|
||||
@aliases[emoji] || emoji
|
||||
|
|
|
@ -377,6 +377,7 @@ class Note < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def award_emoji_name
|
||||
note.match(Gitlab::Markdown::EmojiFilter.emoji_pattern)[1]
|
||||
original_name = note.match(Gitlab::Markdown::EmojiFilter.emoji_pattern)[1]
|
||||
AwardEmoji.normilize_emoji_name(original_name)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}"
|
||||
noteable_type = "#{votable.class.name.underscore}"
|
||||
noteable_id = "#{votable.id}"
|
||||
window.awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id)
|
||||
aliases = #{AwardEmoji::ALIASES.to_json}
|
||||
window.awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id, aliases)
|
||||
|
||||
$(".awards-menu li").click (e)->
|
||||
emoji = $(this).data("emoji")
|
||||
|
|
|
@ -6,7 +6,42 @@ class AwardEmoji
|
|||
"ambulance", "anguished", "two_hearts", "wink"
|
||||
]
|
||||
|
||||
ALIASES = {
|
||||
pout: "rage",
|
||||
satisfied: "laughing",
|
||||
hankey: "shit",
|
||||
poop: "shit",
|
||||
collision: "boom",
|
||||
thumbsup: "+1",
|
||||
thumbsdown: "-1",
|
||||
punch: "facepunch",
|
||||
raised_hand: "hand",
|
||||
running: "runner",
|
||||
ng_woman: "no_good",
|
||||
shoe: "mans_shoe",
|
||||
tshirt: "shirt",
|
||||
honeybee: "bee",
|
||||
flipper: "dolphin",
|
||||
paw_prints: "feet",
|
||||
waxing_gibbous_moon: "moon",
|
||||
telephone: "phone",
|
||||
knife: "hocho",
|
||||
envelope: "email",
|
||||
pencil: "memo",
|
||||
open_book: "book",
|
||||
sailboat: "boat",
|
||||
red_car: "car",
|
||||
lantern: "izakaya_lantern",
|
||||
uk: "gb",
|
||||
heavy_exclamation_mark: "exclamation",
|
||||
squirrel: "shipit"
|
||||
}.with_indifferent_access
|
||||
|
||||
def self.path_to_emoji_image(name)
|
||||
"emoji/#{Emoji.emoji_filename(name)}.png"
|
||||
end
|
||||
|
||||
def self.normilize_emoji_name(name)
|
||||
ALIASES[name] || name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -159,4 +159,13 @@ describe Note, models: true do
|
|||
expect(note.editable?).to be_falsy
|
||||
end
|
||||
end
|
||||
|
||||
describe "set_award!" do
|
||||
let(:issue) { create :issue }
|
||||
|
||||
it "converts aliases to actual name" do
|
||||
note = create :note, note: ":thumbsup:", noteable: issue
|
||||
expect(note.reload.note).to eq("+1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue