diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-25 17:07:54 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-25 17:07:54 +0400 |
commit | 6cc4ac7b98b0fb2ba028644fd8dc4e2d89b65e2a (patch) | |
tree | 2f488684fe680653278d8cf84868770e897819e7 /app/observers | |
parent | 12d081008da393a4e2d2c931b7898875e565d8d5 (diff) |
Drop activity observer. User EventCreateService instead
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/observers')
-rw-r--r-- | app/observers/activity_observer.rb | 35 | ||||
-rw-r--r-- | app/observers/base_observer.rb | 4 | ||||
-rw-r--r-- | app/observers/issue_observer.rb | 3 |
3 files changed, 7 insertions, 35 deletions
diff --git a/app/observers/activity_observer.rb b/app/observers/activity_observer.rb deleted file mode 100644 index c5420c275ae..00000000000 --- a/app/observers/activity_observer.rb +++ /dev/null @@ -1,35 +0,0 @@ -class ActivityObserver < BaseObserver - observe :issue, :note, :milestone - - def after_create(record) - if record.kind_of?(Note) - # Skip system notes, like status changes and cross-references. - return true if record.system? - - # Skip wall notes to prevent spamming of dashboard - return true if record.noteable_type.blank? - end - - create_event(record, Event.determine_action(record)) if current_user - end - - def after_close(record, transition) - create_event(record, Event::CLOSED) - end - - def after_reopen(record, transition) - create_event(record, Event::REOPENED) - end - - protected - - def create_event(record, status) - Event.create( - project: record.project, - target_id: record.id, - target_type: record.class.name, - action: status, - author_id: current_user.id - ) - end -end diff --git a/app/observers/base_observer.rb b/app/observers/base_observer.rb index f9a0242ce77..d685bd5d819 100644 --- a/app/observers/base_observer.rb +++ b/app/observers/base_observer.rb @@ -3,6 +3,10 @@ class BaseObserver < ActiveRecord::Observer NotificationService.new end + def event_service + EventCreateService.new + end + def log_info message Gitlab::AppLogger.info message end diff --git a/app/observers/issue_observer.rb b/app/observers/issue_observer.rb index 6ef13eb5d5e..30da1f83da7 100644 --- a/app/observers/issue_observer.rb +++ b/app/observers/issue_observer.rb @@ -1,17 +1,20 @@ class IssueObserver < BaseObserver def after_create(issue) notification.new_issue(issue, current_user) + event_service.open_issue(issue, current_user) issue.create_cross_references!(issue.project, current_user) execute_hooks(issue) end def after_close(issue, transition) notification.close_issue(issue, current_user) + event_service.close_issue(issue, current_user) create_note(issue) execute_hooks(issue) end def after_reopen(issue, transition) + event_service.reopen_issue(issue, current_user) create_note(issue) execute_hooks(issue) end |