summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-17 17:45:32 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-20 12:12:05 -0200
commit1d476b0656b3ec24e264d7a7c30bdca83704b3bd (patch)
treed1cdb1b22c0f1365efd80a0485e25b1ecfaf7735 /app/services
parent14fc05ebfdfb6654859ee6f57aa462420a6bcb56 (diff)
downloadgitlab-ce-1d476b0656b3ec24e264d7a7c30bdca83704b3bd.tar.gz
Create a pending task when a user is mentioned on a note
Diffstat (limited to 'app/services')
-rw-r--r--app/services/task_service.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/services/task_service.rb b/app/services/task_service.rb
index fa615f4cfcf..d97fa146f5c 100644
--- a/app/services/task_service.rb
+++ b/app/services/task_service.rb
@@ -77,7 +77,17 @@ class TaskService
def new_note(note)
# Skip system notes, like status changes and cross-references
unless note.system
- mark_pending_tasks_as_done(note.noteable, note.author)
+ project = note.project
+ target = note.noteable
+ author = note.author
+
+ mark_pending_tasks_as_done(target, author)
+
+ mentioned_users = build_mentioned_users(project, note, author)
+
+ mentioned_users.each do |user|
+ create_task(project, target, author, user, Task::MENTIONED, note)
+ end
end
end
@@ -94,14 +104,15 @@ class TaskService
private
- def create_task(project, target, author, user, action)
+ def create_task(project, target, author, user, action, note = nil)
attributes = {
project: project,
user_id: user.id,
author_id: author.id,
target_id: target.id,
target_type: target.class.name,
- action: action
+ action: action,
+ note: note
}
Task.create(attributes)