2013-03-26 12:11:38 -04:00
|
|
|
class IssueObserver < BaseObserver
|
2012-05-17 17:23:34 -04:00
|
|
|
def after_create(issue)
|
2013-03-26 03:47:40 -04:00
|
|
|
notification.new_issue(issue, current_user)
|
2013-05-30 19:16:49 -04:00
|
|
|
issue.create_cross_references!(issue.project, current_user)
|
2013-12-03 04:34:06 -05:00
|
|
|
execute_hooks(issue)
|
2012-05-17 17:23:34 -04:00
|
|
|
end
|
|
|
|
|
2013-02-18 04:10:58 -05:00
|
|
|
def after_close(issue, transition)
|
2013-03-26 03:47:40 -04:00
|
|
|
notification.close_issue(issue, current_user)
|
2013-02-18 04:10:58 -05:00
|
|
|
create_note(issue)
|
2013-12-03 04:34:06 -05:00
|
|
|
execute_hooks(issue)
|
2013-02-18 04:10:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_reopen(issue, transition)
|
|
|
|
create_note(issue)
|
2013-12-19 10:23:22 -05:00
|
|
|
execute_hooks(issue)
|
2013-02-18 04:10:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_update(issue)
|
2013-03-26 03:47:40 -04:00
|
|
|
if issue.is_being_reassigned?
|
|
|
|
notification.reassigned_issue(issue, current_user)
|
2013-12-26 11:50:29 -05:00
|
|
|
create_assignee_note(issue)
|
2013-03-26 03:47:40 -04:00
|
|
|
end
|
2013-05-30 19:16:49 -04:00
|
|
|
|
|
|
|
issue.notice_added_references(issue.project, current_user)
|
2013-12-19 10:23:22 -05:00
|
|
|
execute_hooks(issue)
|
2012-05-20 14:25:34 -04:00
|
|
|
end
|
|
|
|
|
2012-06-20 21:23:05 -04:00
|
|
|
protected
|
|
|
|
|
2013-03-26 03:47:40 -04:00
|
|
|
# Create issue note with service comment like 'Status changed to closed'
|
2013-02-18 04:10:58 -05:00
|
|
|
def create_note(issue)
|
2013-05-30 19:16:49 -04:00
|
|
|
Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit)
|
2013-02-18 04:10:58 -05:00
|
|
|
end
|
2013-12-03 04:34:06 -05:00
|
|
|
|
2013-12-26 11:50:29 -05:00
|
|
|
def create_assignee_note(issue)
|
|
|
|
Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee)
|
|
|
|
end
|
|
|
|
|
2013-12-03 04:34:06 -05:00
|
|
|
def execute_hooks(issue)
|
|
|
|
issue.project.execute_hooks(issue.to_hook_data, :issue_hooks)
|
|
|
|
end
|
2012-05-17 17:23:34 -04:00
|
|
|
end
|