diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities/issue.rb | 9 | ||||
-rw-r--r-- | lib/banzai/filter/references/reference_cache.rb | 31 |
2 files changed, 21 insertions, 19 deletions
diff --git a/lib/api/entities/issue.rb b/lib/api/entities/issue.rb index 56e942a0383..79adad92d6f 100644 --- a/lib/api/entities/issue.rb +++ b/lib/api/entities/issue.rb @@ -55,7 +55,14 @@ module API end expose :moved_to_id - expose :service_desk_reply_to + expose :service_desk_reply_to do |issue| + issue.present( + current_user: options[:current_user], + # We need to pass it explicitly to account for the case where `issue` + # is a `WorkItem` which doesn't have a presenter yet. + presenter_class: IssuePresenter + ).service_desk_reply_to + end end end end diff --git a/lib/banzai/filter/references/reference_cache.rb b/lib/banzai/filter/references/reference_cache.rb index c8370d5f9c1..759c34ab7e6 100644 --- a/lib/banzai/filter/references/reference_cache.rb +++ b/lib/banzai/filter/references/reference_cache.rb @@ -29,15 +29,19 @@ module Banzai @references_per_parent[parent_type] ||= begin refs = Hash.new { |hash, key| hash[key] = Set.new } - prepare_doc_for_scan.to_enum(:scan, regex).each do - parent_path = if parent_type == :project - full_project_path($~[:namespace], $~[:project]) - else - full_group_path($~[:group]) - end - - ident = filter.identifier($~) - refs[parent_path] << ident if ident + [filter.object_class.link_reference_pattern, filter.object_class.reference_pattern].each do |pattern| + next unless pattern + + prepare_doc_for_scan.to_enum(:scan, pattern).each do + parent_path = if parent_type == :project + full_project_path($~[:namespace], $~[:project]) + else + full_group_path($~[:group]) + end + + ident = filter.identifier($~) + refs[parent_path] << ident if ident + end end refs @@ -171,15 +175,6 @@ module Banzai delegate :project, :group, :parent, :parent_type, to: :filter - def regex - strong_memoize(:regex) do - [ - filter.object_class.link_reference_pattern, - filter.object_class.reference_pattern - ].compact.reduce { |a, b| Regexp.union(a, b) } - end - end - def refs_cache Gitlab::SafeRequestStore["banzai_#{parent_type}_refs".to_sym] ||= {} end |