diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /app/models/note.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 25 |
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 |