summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 2ad6df85e5f..34ffd7c91af 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -5,6 +5,8 @@
# A note of this type is never resolvable.
class Note < ApplicationRecord
extend ActiveModel::Naming
+ extend Gitlab::Utils::Override
+
include Gitlab::Utils::StrongMemoize
include Participable
include Mentionable
@@ -576,6 +578,29 @@ class Note < ApplicationRecord
review.present? || !author.can_trigger_notifications?
end
+ def post_processed_cache_key
+ cache_key_items = [cache_key, author.cache_key]
+ cache_key_items << Digest::SHA1.hexdigest(redacted_note_html) if redacted_note_html.present?
+
+ cache_key_items.join(':')
+ end
+
+ override :user_mention_class
+ def user_mention_class
+ return if noteable.blank?
+
+ noteable.user_mention_class
+ end
+
+ override :user_mention_identifier
+ def user_mention_identifier
+ return if noteable.blank?
+
+ noteable.user_mention_identifier.merge({
+ note_id: id
+ })
+ end
+
private
# Using this method followed by a call to *save* may result in *ActiveRecord::RecordNotUnique* exception