update_service.rb 1.3 KB
Newer Older
1
module Issues
D
Dmitriy Zaporozhets 已提交
2
  class UpdateService < Issues::BaseService
3
    def execute(issue)
4
      update(issue)
5
    end
6

7 8
    def handle_changes(issue, old_labels: [])
      if has_changes?(issue, old_labels: old_labels)
9
        todo_service.mark_pending_todos_as_done(issue, current_user)
10 11 12
      end

      if issue.previous_changes.include?('title') ||
13
         issue.previous_changes.include?('description')
14
        todo_service.update_issue(issue, current_user)
15 16
      end

17 18 19 20 21 22 23
      if issue.previous_changes.include?('milestone_id')
        create_milestone_note(issue)
      end

      if issue.previous_changes.include?('assignee_id')
        create_assignee_note(issue)
        notification_service.reassigned_issue(issue, current_user)
24
        todo_service.reassigned_issue(issue, current_user)
25
      end
26

27 28 29 30
      if issue.previous_changes.include?('confidential')
        create_confidentiality_note(issue)
      end

31 32 33
      added_labels = issue.labels - old_labels
      if added_labels.present?
        notification_service.relabeled_issue(issue, added_labels, current_user)
34
      end
35
    end
36 37 38 39 40 41 42 43

    def reopen_service
      Issues::ReopenService
    end

    def close_service
      Issues::CloseService
    end
44 45 46 47 48 49

    private

    def create_confidentiality_note(issue)
      SystemNoteService.change_issue_confidentiality(issue, issue.project, current_user)
    end
50 51
  end
end