emoji aliases problem
This commit is contained in:
parent
cd97dba2a9
commit
72b7d1f59d
|
@ -43,6 +43,7 @@ v 8.3.0 (unreleased)
|
||||||
- Prevent possible XSS attack with award-emoji
|
- Prevent possible XSS attack with award-emoji
|
||||||
- Upgraded Sidekiq to 4.x
|
- Upgraded Sidekiq to 4.x
|
||||||
- Accept COPYING,COPYING.lesser, and licence as license file (Zeger-Jan van de Weg)
|
- Accept COPYING,COPYING.lesser, and licence as license file (Zeger-Jan van de Weg)
|
||||||
|
- Fix emoji aliases problem
|
||||||
|
|
||||||
v 8.2.3
|
v 8.2.3
|
||||||
- Fix application settings cache not expiring after changes (Stan Hu)
|
- Fix application settings cache not expiring after changes (Stan Hu)
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
class @AwardsHandler
|
class @AwardsHandler
|
||||||
constructor: (@post_emoji_url, @noteable_type, @noteable_id) ->
|
constructor: (@post_emoji_url, @noteable_type, @noteable_id, @aliases) ->
|
||||||
|
|
||||||
addAward: (emoji) ->
|
addAward: (emoji) ->
|
||||||
|
emoji = @normilizeEmojiName(emoji)
|
||||||
@postEmoji emoji, =>
|
@postEmoji emoji, =>
|
||||||
@addAwardToEmojiBar(emoji)
|
@addAwardToEmojiBar(emoji)
|
||||||
|
|
||||||
addAwardToEmojiBar: (emoji, custom_path = '') ->
|
addAwardToEmojiBar: (emoji, custom_path = '') ->
|
||||||
|
emoji = @normilizeEmojiName(emoji)
|
||||||
if @exist(emoji)
|
if @exist(emoji)
|
||||||
if @isActive(emoji)
|
if @isActive(emoji)
|
||||||
@decrementCounter(emoji)
|
@decrementCounter(emoji)
|
||||||
|
@ -94,3 +96,6 @@ class @AwardsHandler
|
||||||
$('body, html').animate({
|
$('body, html').animate({
|
||||||
scrollTop: $('.awards').offset().top - 80
|
scrollTop: $('.awards').offset().top - 80
|
||||||
}, 200)
|
}, 200)
|
||||||
|
|
||||||
|
normilizeEmojiName: (emoji) ->
|
||||||
|
@aliases[emoji] || emoji
|
||||||
|
|
|
@ -377,6 +377,7 @@ class Note < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def award_emoji_name
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}"
|
post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}"
|
||||||
noteable_type = "#{votable.class.name.underscore}"
|
noteable_type = "#{votable.class.name.underscore}"
|
||||||
noteable_id = "#{votable.id}"
|
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)->
|
$(".awards-menu li").click (e)->
|
||||||
emoji = $(this).data("emoji")
|
emoji = $(this).data("emoji")
|
||||||
|
|
|
@ -6,7 +6,42 @@ class AwardEmoji
|
||||||
"ambulance", "anguished", "two_hearts", "wink"
|
"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)
|
def self.path_to_emoji_image(name)
|
||||||
"emoji/#{Emoji.emoji_filename(name)}.png"
|
"emoji/#{Emoji.emoji_filename(name)}.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.normilize_emoji_name(name)
|
||||||
|
ALIASES[name] || name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -159,4 +159,13 @@ describe Note, models: true do
|
||||||
expect(note.editable?).to be_falsy
|
expect(note.editable?).to be_falsy
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue