diff options
author | Ershad Kunnakkadan <ershad92@gmail.com> | 2016-12-05 17:42:22 +0530 |
---|---|---|
committer | Ershad Kunnakkadan <ershad92@gmail.com> | 2017-02-08 21:53:34 +0530 |
commit | 3a23639bc04729cfdc37e4b8ebf46358c3d5a137 (patch) | |
tree | db89ec896fd36ace8c2fc642e66106d9dfbec903 /app/models/concerns | |
parent | 11d33873a8da5f90fd00bf0909dd1e9f8fca1448 (diff) | |
download | gitlab-ce-3a23639bc04729cfdc37e4b8ebf46358c3d5a137.tar.gz |
Create directly_addressed Todos when mentioned in beginning of a line
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/mentionable.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index ef2c1e5d414..7e56e371b27 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -44,8 +44,15 @@ module Mentionable end def all_references(current_user = nil, extractor: nil) - extractor ||= Gitlab::ReferenceExtractor. - new(project, current_user) + # Use custom extractor if it's passed in the function parameters. + if extractor + @extractor = extractor + else + @extractor ||= Gitlab::ReferenceExtractor. + new(project, current_user) + + @extractor.reset_memoized_values + end self.class.mentionable_attrs.each do |attr, options| text = __send__(attr) @@ -55,16 +62,20 @@ module Mentionable skip_project_check: skip_project_check? ) - extractor.analyze(text, options) + @extractor.analyze(text, options) end - extractor + @extractor end def mentioned_users(current_user = nil) all_references(current_user).users end + def directly_addressed_users(current_user = nil) + all_references(current_user).directly_addressed_users + end + # Extract GFM references to other Mentionables from this Mentionable. Always excludes its #local_reference. def referenced_mentionables(current_user = self.author) refs = all_references(current_user) |