summaryrefslogtreecommitdiff
path: root/lib/banzai/filter/custom_emoji_filter.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /lib/banzai/filter/custom_emoji_filter.rb
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'lib/banzai/filter/custom_emoji_filter.rb')
-rw-r--r--lib/banzai/filter/custom_emoji_filter.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/banzai/filter/custom_emoji_filter.rb b/lib/banzai/filter/custom_emoji_filter.rb
index a5f1a22c483..ae95c7f66b6 100644
--- a/lib/banzai/filter/custom_emoji_filter.rb
+++ b/lib/banzai/filter/custom_emoji_filter.rb
@@ -8,8 +8,7 @@ module Banzai
IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set
def call
- return doc unless context[:project]
- return doc unless Feature.enabled?(:custom_emoji, context[:project])
+ return doc unless resource_parent
doc.xpath('descendant-or-self::text()').each do |node|
content = node.to_html
@@ -50,12 +49,12 @@ module Banzai
def has_custom_emoji?
strong_memoize(:has_custom_emoji) do
- namespace&.custom_emoji&.any?
+ CustomEmoji.for_resource(resource_parent).any?
end
end
- def namespace
- context[:project].namespace.root_ancestor
+ def resource_parent
+ context[:project] || context[:group]
end
def custom_emoji_candidates
@@ -63,7 +62,8 @@ module Banzai
end
def all_custom_emoji
- @all_custom_emoji ||= namespace.custom_emoji.by_name(custom_emoji_candidates).index_by(&:name)
+ @all_custom_emoji ||=
+ CustomEmoji.for_resource(resource_parent).by_name(custom_emoji_candidates).index_by(&:name)
end
end
end