@@ -541,18 +541,19 @@ func (c *Manager) UpdateConversationUserAssignee(uuid string, assigneeID int, ac
541541 return envelope .NewError (envelope .GeneralError , c .i18n .Ts ("globals.messages.errorUpdating" , "name" , "{globals.terms.conversation}" ), nil )
542542 }
543543
544- c .webhookStore .TriggerEvent (wmodels .EventConversationAssigned , map [string ]any {
545- "conversation_uuid" : uuid ,
546- "assigned_to" : assigneeID ,
547- "actor_id" : actor .ID ,
548- })
549-
550544 // Refetch the conversation to get the updated details.
551545 conversation , err := c .GetConversation (0 , uuid , "" )
552546 if err != nil {
553547 return err
554548 }
555549
550+ c .webhookStore .TriggerEvent (wmodels .EventConversationAssigned , map [string ]any {
551+ "conversation_uuid" : uuid ,
552+ "assigned_to" : assigneeID ,
553+ "actor_id" : actor .ID ,
554+ "conversation" : conversation ,
555+ })
556+
556557 // Evaluate automation rules.
557558 c .automation .EvaluateConversationUpdateRules (conversation , amodels .EventConversationUserAssigned )
558559
@@ -715,6 +716,12 @@ func (c *Manager) UpdateConversationStatus(uuid string, statusID int, status, sn
715716 return envelope .NewError (envelope .GeneralError , c .i18n .Ts ("globals.messages.errorUpdating" , "name" , "{globals.terms.conversation}" ), nil )
716717 }
717718
719+ // Fetch conversation for webhook and automation rules.
720+ conversation , err := c .GetConversation (0 , uuid , "" )
721+ if err != nil {
722+ c .lo .Error ("error fetching conversation after status change" , "uuid" , uuid , "error" , err )
723+ }
724+
718725 // Trigger webhook for conversation status change
719726 var snoozeUntilStr string
720727 if ! snoozeUntil .IsZero () {
@@ -726,6 +733,7 @@ func (c *Manager) UpdateConversationStatus(uuid string, statusID int, status, sn
726733 "new_status" : status ,
727734 "snooze_until" : snoozeUntilStr ,
728735 "actor_id" : actor .ID ,
736+ "conversation" : conversation ,
729737 })
730738
731739 // Record the status change as an activity.
@@ -737,10 +745,7 @@ func (c *Manager) UpdateConversationStatus(uuid string, statusID int, status, sn
737745 c .BroadcastConversationUpdate (uuid , "status" , status )
738746
739747 // Evaluate automation rules.
740- conversation , err := c .GetConversation (0 , uuid , "" )
741- if err != nil {
742- c .lo .Error ("error fetching conversation after status change" , "uuid" , uuid , "error" , err )
743- } else {
748+ if conversation .ID != 0 {
744749 c .automation .EvaluateConversationUpdateRules (conversation , amodels .EventConversationStatusChange )
745750 }
746751
@@ -797,6 +802,12 @@ func (c *Manager) SetConversationTags(uuid string, action string, tagNames []str
797802 return envelope .NewError (envelope .GeneralError , c .i18n .Ts ("globals.messages.errorFetching" , "name" , "{globals.terms.tag}" ), nil )
798803 }
799804
805+ // Fetch conversation for webhook.
806+ conversation , err := c .GetConversation (0 , uuid , "" )
807+ if err != nil {
808+ c .lo .Error ("error fetching conversation after tags change" , "uuid" , uuid , "error" , err )
809+ }
810+
800811 // Trigger webhook for conversation tags changed.
801812 if newTags == nil {
802813 newTags = []string {}
@@ -806,6 +817,7 @@ func (c *Manager) SetConversationTags(uuid string, action string, tagNames []str
806817 "previous_tags" : prevTags ,
807818 "new_tags" : newTags ,
808819 "actor_id" : actor .ID ,
820+ "conversation" : conversation ,
809821 })
810822
811823 // Find actually removed tags.
@@ -1146,9 +1158,14 @@ func (m *Manager) RemoveConversationAssignee(uuid, typ string, actor umodels.Use
11461158
11471159 // Trigger webhook for conversation unassigned from user.
11481160 if typ == models .AssigneeTypeUser {
1161+ conversation , err := m .GetConversation (0 , uuid , "" )
1162+ if err != nil {
1163+ m .lo .Error ("error fetching conversation after unassignment" , "uuid" , uuid , "error" , err )
1164+ }
11491165 m .webhookStore .TriggerEvent (wmodels .EventConversationUnassigned , map [string ]any {
11501166 "conversation_uuid" : uuid ,
11511167 "actor_id" : actor .ID ,
1168+ "conversation" : conversation ,
11521169 })
11531170 }
11541171
0 commit comments