summaryrefslogtreecommitdiff
path: root/app/models/concerns/mentionable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/concerns/mentionable.rb')
-rw-r--r--app/models/concerns/mentionable.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index f1baa923ec5..4df9e32d8ec 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -161,6 +161,21 @@ module Mentionable
create_cross_references!(author)
end
+ def user_mention_class
+ user_mention_association.klass
+ end
+
+ # Identifier for the user mention that is parsed from model description rather then its related notes.
+ # Models that have a description attribute like Issue, MergeRequest, Epic, Snippet may have such a user mention.
+ # Other mentionable models like DesignManagement::Design, will never have such record as those do not have
+ # a description attribute.
+ def user_mention_identifier
+ {
+ user_mention_association.foreign_key => id,
+ note_id: nil
+ }
+ end
+
private
def extracted_mentionables(refs)
@@ -199,6 +214,10 @@ module Mentionable
{}
end
+ def user_mention_association
+ association(:user_mentions).reflection
+ end
+
# User mention that is parsed from model description rather then its related notes.
# Models that have a description attribute like Issue, MergeRequest, Epic, Snippet may have such a user mention.
# Other mentionable models like Commit, DesignManagement::Design, will never have such record as those do not have