Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_observer.rb « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 461b3eb0dfe4f0653395fd7061832e7a97d5dabe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class IssueObserver < ActiveRecord::Observer
  cattr_accessor :current_user

  def after_create(issue)
    Notify.new_issue_email(issue.id) if issue.assignee != current_user
  end

  def after_change(issue)
    send_reassigned_email(issue) if issue.is_being_reassigned?
    Note.create_status_change_note(issue, current_user, 'closed') if issue.is_being_closed?
  end

  def send_reassigned_email(issue)
    recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id }

    recipient_ids.each do |recipient_id|
      Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was)
    end
  end
end