gitlab-org--gitlab-foss/app/observers/issue_observer.rb

44 lines
1.1 KiB
Ruby
Raw Normal View History

class IssueObserver < BaseObserver
def after_create(issue)
notification.new_issue(issue, current_user)
issue.create_cross_references!(issue.project, current_user)
execute_hooks(issue)
end
2013-02-18 04:10:58 -05:00
def after_close(issue, transition)
notification.close_issue(issue, current_user)
2013-02-18 04:10:58 -05:00
create_note(issue)
execute_hooks(issue)
2013-02-18 04:10:58 -05:00
end
def after_reopen(issue, transition)
create_note(issue)
execute_hooks(issue)
2013-02-18 04:10:58 -05:00
end
def after_update(issue)
if issue.is_being_reassigned?
notification.reassigned_issue(issue, current_user)
create_assignee_note(issue)
end
issue.notice_added_references(issue.project, current_user)
execute_hooks(issue)
end
protected
# Create issue note with service comment like 'Status changed to closed'
2013-02-18 04:10:58 -05:00
def create_note(issue)
Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit)
2013-02-18 04:10:58 -05:00
end
def create_assignee_note(issue)
Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee)
end
def execute_hooks(issue)
issue.project.execute_hooks(issue.to_hook_data, :issue_hooks)
end
end