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/services/todo_service.rb | |
parent | 11d33873a8da5f90fd00bf0909dd1e9f8fca1448 (diff) | |
download | gitlab-ce-3a23639bc04729cfdc37e4b8ebf46358c3d5a137.tar.gz |
Create directly_addressed Todos when mentioned in beginning of a line
Diffstat (limited to 'app/services/todo_service.rb')
-rw-r--r-- | app/services/todo_service.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 1bd6ce416ab..8ab943f4639 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -243,6 +243,12 @@ class TodoService end def create_mention_todos(project, target, author, note = nil) + # Create Todos for directly addressed users + directly_addressed_users = filter_directly_addressed_users(project, note || target, author) + attributes = attributes_for_todo(project, target, author, Todo::DIRECTLY_ADDRESSED, note) + create_todos(directly_addressed_users, attributes) + + # Create Todos for mentioned users mentioned_users = filter_mentioned_users(project, note || target, author) attributes = attributes_for_todo(project, target, author, Todo::MENTIONED, note) create_todos(mentioned_users, attributes) @@ -282,10 +288,18 @@ class TodoService ) end + def filter_todo_users(users, project, target) + reject_users_without_access(users, project, target).uniq + end + def filter_mentioned_users(project, target, author) mentioned_users = target.mentioned_users(author) - mentioned_users = reject_users_without_access(mentioned_users, project, target) - mentioned_users.uniq + filter_todo_users(mentioned_users, project, target) + end + + def filter_directly_addressed_users(project, target, author) + directly_addressed_users = target.directly_addressed_users(author) + filter_todo_users(directly_addressed_users, project, target) end def reject_users_without_access(users, project, target) |