11class IssuesController < AuthenticatedController
2- include ActivityTracking
32 include ConflictResolver
43 include ContentFromTemplate
54 include DynamicFieldNamesCacher
5+ include EventPublisher
66 include IssuesHelper
77 include LiquidEnabledResource
88 include Mentioned
@@ -47,22 +47,21 @@ def create
4747
4848 respond_to do |format |
4949 if @issue . save &&
50- # FIXME: need to fix Taggable concern.
51- #
52- # For some reason we can't save the :tags before we save the model,
53- # so first we save it, then we apply the tags.
54- #
55- # See #set_or_initialize_issue()
56- #
57- @issue . update ( issue_params )
58-
59- track_created ( @issue )
50+ # FIXME: need to fix Taggable concern.
51+ #
52+ # For some reason we can't save the :tags before we save the model,
53+ # so first we save it, then we apply the tags.
54+ #
55+ # See #set_or_initialize_issue()
56+ #
57+ @issue . update ( issue_params )
6058
6159 # Only after we save the issue, we can create valid taggings (w/ valid
6260 # taggable IDs)
6361 @issue . tag_from_field_content!
6462
6563 format . html { redirect_to [ current_project , @issue ] , notice : 'Issue added.' }
64+ publish_event ( 'issue.created' , @issue . to_event_payload )
6665 else
6766 format . html do
6867 flash . now [ :alert ] = 'Issue couldn\'t be added.'
@@ -84,8 +83,8 @@ def update
8483 if @issue . update ( issue_params )
8584 @modified = true
8685 check_for_edit_conflicts ( @issue , updated_at_before_save )
87- track_updated ( @issue )
8886 format . html { redirect_to_main_or_qa }
87+ publish_event ( 'issue.updated' , @issue . to_event_payload )
8988 else
9089 format . html do
9190 flash . now [ :alert ] = 'Issue couldn\'t be updated.'
@@ -100,9 +99,9 @@ def update
10099 def destroy
101100 respond_to do |format |
102101 if @issue . destroy
103- track_destroyed ( @issue )
104102 format . html { redirect_to project_issues_path ( current_project ) , notice : 'Issue deleted.' }
105103 format . json
104+ publish_event ( 'issue.destroyed' , @issue . to_event_payload )
106105 else
107106 format . html { redirect_to project_issues_path ( current_project ) , notice : "Error while deleting issue: #{ @issue . errors } " }
108107 format . json
0 commit comments