chore: Add controllers for conversation participants (#6462)

Co-authored-by: Aswin Dev P.S <aswindevps@gmail.com>
Co-authored-by: Sojan Jose <sojan@chatwoot.com>
This commit is contained in:
Pranav Raj S
2023-02-15 16:33:31 -08:00
committed by GitHub
parent 949ddf68ba
commit 7044eda281
34 changed files with 546 additions and 63 deletions

View File

@@ -4,7 +4,7 @@ module AssignmentHandler
included do
before_save :ensure_assignee_is_from_team
after_commit :notify_assignment_change, :process_assignment_activities
after_commit :notify_assignment_change, :process_assignment_changes
end
private
@@ -36,6 +36,11 @@ module AssignmentHandler
end
end
def process_assignment_changes
process_assignment_activities
process_participant_assignment
end
def process_assignment_activities
user_name = Current.user.name if Current.user.present?
if saved_change_to_team_id?
@@ -44,4 +49,10 @@ module AssignmentHandler
create_assignee_change_activity(user_name)
end
end
def process_participant_assignment
return unless saved_change_to_assignee_id? && assignee_id.present?
conversation_participants.find_or_create_by!(user_id: assignee_id)
end
end