Documentation
¶
Overview ¶
Package conversation manages conversations and messages.
Index ¶
- type Manager
- func (c *Manager) ActiveUserConversationsCount(userID int) (int, error)
- func (m *Manager) ApplyAction(action amodels.RuleAction, conv models.Conversation, user umodels.User) error
- func (m *Manager) ApplySLA(conversation models.Conversation, policyID int, actor umodels.User) error
- func (m *Manager) BroadcastConversationUpdate(conversationUUID, prop string, value any)
- func (m *Manager) BroadcastMessageUpdate(conversationUUID, messageUUID, prop string, value any)
- func (m *Manager) BroadcastNewMessage(message *cmodels.Message)
- func (m *Manager) Close()
- func (m *Manager) CreateContactMessage(media []mmodels.Media, contactID int, ...) (models.Message, error)
- func (c *Manager) CreateConversation(contactID, contactChannelID, inboxID int, lastMessage string, ...) (int, string, error)
- func (m *Manager) DeleteConversation(uuid string) error
- func (m *Manager) DeleteConversationDraft(conversationID int, uuid string, userID int) error
- func (m *Manager) DeleteStaleDrafts(ctx context.Context, retentionPeriod time.Duration) error
- func (m *Manager) EnqueueIncoming(message models.IncomingMessage) error
- func (c *Manager) GetAllConversationsList(viewingUserID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
- func (m *Manager) GetAllUserDrafts(userID int) ([]models.ConversationDraft, error)
- func (c *Manager) GetAssignedConversationsList(viewingUserID, userID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
- func (c *Manager) GetContactPreviousConversations(contactID int, limit int) ([]models.PreviousConversation, error)
- func (c *Manager) GetConversation(id int, uuid, refNum string) (models.Conversation, error)
- func (m *Manager) GetConversationByMessageID(id int) (models.Conversation, error)
- func (m *Manager) GetConversationMessages(conversationUUID string, page, pageSize int, private *bool, msgTypes []string) ([]models.Message, int, error)
- func (c *Manager) GetConversationParticipants(uuid string) ([]models.ConversationParticipant, error)
- func (c *Manager) GetConversationUUID(id int) (string, error)
- func (c *Manager) GetConversations(viewingUserID, userID int, teamIDs []int, listTypes []string, ...) ([]models.ConversationListItem, error)
- func (c *Manager) GetConversationsCreatedAfter(time time.Time) ([]models.Conversation, error)
- func (c *Manager) GetMentionedConversationsList(viewingUserID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
- func (m *Manager) GetMessage(uuid string) (models.Message, error)
- func (m *Manager) GetMessageSourceIDs(conversationID, limit int) ([]string, error)
- func (c *Manager) GetTeamUnassignedConversationsList(viewingUserID, teamID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
- func (c *Manager) GetUnassignedConversations() ([]models.Conversation, error)
- func (c *Manager) GetUnassignedConversationsList(viewingUserID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
- func (c *Manager) GetViewConversationsList(viewingUserID, userID int, teamIDs []int, listType []string, ...) ([]models.ConversationListItem, error)
- func (m *Manager) IncomingMessageWorker(ctx context.Context)
- func (m *Manager) InsertConversationActivity(activityType, conversationUUID, newValue string, actor umodels.User) error
- func (c *Manager) InsertMentions(conversationID, messageID, mentionedByUserID int, ...) error
- func (m *Manager) InsertMessage(message *models.Message) error
- func (c *Manager) MarkAsUnread(uuid string, userID int) error
- func (m *Manager) MarkMessageAsPending(uuid string) error
- func (m *Manager) MessageExists(messageID string) (bool, error)
- func (m *Manager) MessageSenderWorker(ctx context.Context)
- func (m *Manager) NotifyAssignment(userIDs []int, conversation models.Conversation) error
- func (m *Manager) NotifyMention(conversationUUID string, message models.Message, ...)
- func (m *Manager) QueueReply(media []mmodels.Media, inboxID, senderID int, conversationUUID, content string, ...) (models.Message, error)
- func (c *Manager) ReOpenConversation(conversationUUID string, actor umodels.User) error
- func (m *Manager) RecordAssigneeTeamChange(conversationUUID string, teamID int, actor umodels.User) error
- func (m *Manager) RecordAssigneeUserChange(conversationUUID string, assigneeID int, actor umodels.User) error
- func (m *Manager) RecordPriorityChange(priority, conversationUUID string, actor umodels.User) error
- func (m *Manager) RecordSLASet(conversationUUID string, slaName string, actor umodels.User) error
- func (m *Manager) RecordStatusChange(status, conversationUUID string, actor umodels.User) error
- func (m *Manager) RecordTagAddition(conversationUUID string, tag string, actor umodels.User) error
- func (m *Manager) RecordTagRemoval(conversationUUID string, tag string, actor umodels.User) error
- func (m *Manager) RemoveConversationAssignee(uuid, typ string, actor umodels.User) error
- func (m *Manager) RenderMessageInTemplate(channel string, message *models.Message) error
- func (m *Manager) Run(ctx context.Context, ...)
- func (c *Manager) RunDraftCleaner(ctx context.Context, retentionPeriod time.Duration)
- func (c *Manager) RunUnsnoozer(ctx context.Context, unsnoozeInterval time.Duration)
- func (m *Manager) SendCSATReply(actorUserID int, conversation models.Conversation) error
- func (m *Manager) SendPrivateNote(media []mmodels.Media, senderID int, conversationUUID, content string, ...) (models.Message, error)
- func (c *Manager) SetConversationTags(uuid string, action string, tagNames []string, actor umodels.User) error
- func (m *Manager) UnassignOpen(userID int) error
- func (c *Manager) UpdateAssignee(uuid string, assigneeID int, assigneeType string) error
- func (c *Manager) UpdateConversationCustomAttributes(uuid string, customAttributes map[string]any) error
- func (c *Manager) UpdateConversationFirstReplyAt(conversationUUID string, conversationID int, at time.Time) error
- func (c *Manager) UpdateConversationLastMessage(conversation int, ...) error
- func (c *Manager) UpdateConversationLastReplyAt(conversationUUID string, conversationID int, at time.Time) error
- func (c *Manager) UpdateConversationPriority(uuid string, priorityID int, priority string, actor umodels.User) error
- func (c *Manager) UpdateConversationStatus(uuid string, statusID int, status, snoozeDur string, actor umodels.User) error
- func (c *Manager) UpdateConversationTeamAssignee(uuid string, teamID int, actor umodels.User) error
- func (c *Manager) UpdateConversationUserAssignee(uuid string, assigneeID int, actor umodels.User) error
- func (c *Manager) UpdateConversationWaitingSince(conversationUUID string, at *time.Time) error
- func (m *Manager) UpdateMessageStatus(messageUUID string, status string) error
- func (c *Manager) UpdateUserLastSeen(uuid string, userID int) error
- func (m *Manager) UpsertConversationDraft(conversationID, userID int, content string, meta json.RawMessage) (models.ConversationDraft, error)
- type Opts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the operations related to conversations
func New ¶
func New( wsHub *ws.Hub, i18n *i18n.I18n, slaStore slaStore, statusStore statusStore, priorityStore priorityStore, inboxStore inboxStore, userStore userStore, teamStore teamStore, mediaStore mediaStore, settingsStore settingsStore, csatStore csatStore, automation *automation.Engine, template *template.Manager, webhook webhookStore, dispatcher *notifier.Dispatcher, opts Opts) (*Manager, error)
New initializes a new conversation Manager.
func (*Manager) ActiveUserConversationsCount ¶
ActiveUserConversationsCount returns the count of active conversations for a user. i.e. conversations not closed or resolved status.
func (*Manager) ApplyAction ¶
func (m *Manager) ApplyAction(action amodels.RuleAction, conv models.Conversation, user umodels.User) error
ApplyAction applies an action to a conversation, this can be called from multiple packages across the app to perform actions on conversations. all actions are executed on behalf of the provided user if the user is not provided, system user is used.
func (*Manager) ApplySLA ¶
func (m *Manager) ApplySLA(conversation models.Conversation, policyID int, actor umodels.User) error
ApplySLA applies the SLA policy to a conversation.
func (*Manager) BroadcastConversationUpdate ¶
BroadcastConversationUpdate broadcasts a conversation update to all users.
func (*Manager) BroadcastMessageUpdate ¶
BroadcastMessageUpdate broadcasts a message update to all users.
func (*Manager) BroadcastNewMessage ¶
BroadcastNewMessage broadcasts a new message to all users.
func (*Manager) Close ¶
func (m *Manager) Close()
Close signals the Manager to stop processing messages, closes channels, and waits for all worker goroutines to finish processing.
func (*Manager) CreateContactMessage ¶
func (m *Manager) CreateContactMessage(media []mmodels.Media, contactID int, conversationUUID, content, contentType string) (models.Message, error)
CreateContactMessage creates a contact message in a conversation.
func (*Manager) CreateConversation ¶
func (c *Manager) CreateConversation(contactID, contactChannelID, inboxID int, lastMessage string, lastMessageAt time.Time, subject string, appendRefNumToSubject bool) (int, string, error)
CreateConversation creates a new conversation and returns its ID and UUID.
func (*Manager) DeleteConversation ¶
DeleteConversation deletes a conversation.
func (*Manager) DeleteConversationDraft ¶
DeleteConversationDraft deletes a draft for a conversation by ID or UUID.
func (*Manager) DeleteStaleDrafts ¶
DeleteStaleDrafts deletes drafts older than the specified retention period.
func (*Manager) EnqueueIncoming ¶
func (m *Manager) EnqueueIncoming(message models.IncomingMessage) error
EnqueueIncoming enqueues an incoming message for inserting in db.
func (*Manager) GetAllConversationsList ¶
func (c *Manager) GetAllConversationsList(viewingUserID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
GetAllConversationsList retrieves all conversations with optional filtering, ordering, and pagination.
func (*Manager) GetAllUserDrafts ¶
func (m *Manager) GetAllUserDrafts(userID int) ([]models.ConversationDraft, error)
GetAllUserDrafts retrieves all drafts for a user.
func (*Manager) GetAssignedConversationsList ¶
func (c *Manager) GetAssignedConversationsList(viewingUserID, userID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
GetAssignedConversationsList retrieves conversations assigned to a specific user with optional filtering, ordering, and pagination.
func (*Manager) GetContactPreviousConversations ¶
func (c *Manager) GetContactPreviousConversations(contactID int, limit int) ([]models.PreviousConversation, error)
GetContactPreviousConversations retrieves previous conversations for a contact with a configurable limit.
func (*Manager) GetConversation ¶
GetConversation retrieves a conversation by its ID or UUID.
func (*Manager) GetConversationByMessageID ¶
func (m *Manager) GetConversationByMessageID(id int) (models.Conversation, error)
GetConversationByMessageID returns conversation by message id.
func (*Manager) GetConversationMessages ¶
func (m *Manager) GetConversationMessages(conversationUUID string, page, pageSize int, private *bool, msgTypes []string) ([]models.Message, int, error)
GetConversationMessages retrieves messages for a specific conversation.
func (*Manager) GetConversationParticipants ¶
func (c *Manager) GetConversationParticipants(uuid string) ([]models.ConversationParticipant, error)
GetConversationParticipants retrieves the participants of a conversation.
func (*Manager) GetConversationUUID ¶
GetConversationUUID retrieves the UUID of a conversation by its ID.
func (*Manager) GetConversations ¶
func (c *Manager) GetConversations(viewingUserID, userID int, teamIDs []int, listTypes []string, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
GetConversations retrieves conversations list based on user ID, type, and optional filtering, ordering, and pagination. viewingUserID is used to calculate per-agent unread counts.
func (*Manager) GetConversationsCreatedAfter ¶
GetConversationsCreatedAfter retrieves conversations created after the specified time.
func (*Manager) GetMentionedConversationsList ¶
func (c *Manager) GetMentionedConversationsList(viewingUserID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
GetMentionedConversationsList retrieves conversations where the user is mentioned (directly or via team).
func (*Manager) GetMessage ¶
GetMessage retrieves a message by UUID.
func (*Manager) GetMessageSourceIDs ¶
GetMessageSourceIDs retrieves source IDs for messages in a conversation in descending order. So the oldest message will be the last in the list.
func (*Manager) GetTeamUnassignedConversationsList ¶
func (c *Manager) GetTeamUnassignedConversationsList(viewingUserID, teamID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
GetTeamUnassignedConversationsList retrieves conversations assigned to a team with optional filtering, ordering, and pagination.
func (*Manager) GetUnassignedConversations ¶
func (c *Manager) GetUnassignedConversations() ([]models.Conversation, error)
GetUnassignedConversations retrieves unassigned conversations.
func (*Manager) GetUnassignedConversationsList ¶
func (c *Manager) GetUnassignedConversationsList(viewingUserID int, order, orderBy, filters string, page, pageSize int) ([]models.ConversationListItem, error)
GetUnassignedConversationsList retrieves conversations assigned to a team the user is part of with optional filtering, ordering, and pagination.
func (*Manager) GetViewConversationsList ¶
func (*Manager) IncomingMessageWorker ¶
IncomingMessageWorker processes incoming messages from the incoming message queue.
func (*Manager) InsertConversationActivity ¶
func (m *Manager) InsertConversationActivity(activityType, conversationUUID, newValue string, actor umodels.User) error
InsertConversationActivity inserts an activity message.
func (*Manager) InsertMentions ¶
func (c *Manager) InsertMentions(conversationID, messageID, mentionedByUserID int, mentions []models.MentionInput) error
InsertMentions inserts mentions for a message.
func (*Manager) InsertMessage ¶
InsertMessage inserts a message and attaches the media to the message.
func (*Manager) MarkAsUnread ¶
MarkAsUnread marks a conversation as unread for a specific user by setting last_seen to before the last message.
func (*Manager) MarkMessageAsPending ¶
MarkMessageAsPending updates message status to `Pending`, enqueuing it for sending.
func (*Manager) MessageExists ¶
MessageExists checks if a message with the given messageID exists.
func (*Manager) MessageSenderWorker ¶
MessageSenderWorker sends outgoing pending messages.
func (*Manager) NotifyAssignment ¶
func (m *Manager) NotifyAssignment(userIDs []int, conversation models.Conversation) error
NotifyAssignment sends notifications (in-app, WebSocket, email) for an assigned conversation.
func (*Manager) NotifyMention ¶
func (m *Manager) NotifyMention(conversationUUID string, message models.Message, mentions []models.MentionInput, mentionedByUserID int)
NotifyMention sends notifications (in-app, WebSocket, email) for mentions. For team mentions, expands to all team members.
func (*Manager) QueueReply ¶
func (m *Manager) QueueReply(media []mmodels.Media, inboxID, senderID int, conversationUUID, content string, to, cc, bcc []string, meta map[string]interface{}) (models.Message, error)
QueueReply queues a reply message in a conversation.
func (*Manager) ReOpenConversation ¶
ReOpenConversation reopens a conversation if it's snoozed, resolved or closed.
func (*Manager) RecordAssigneeTeamChange ¶
func (m *Manager) RecordAssigneeTeamChange(conversationUUID string, teamID int, actor umodels.User) error
RecordAssigneeTeamChange records an activity for a team assignee change.
func (*Manager) RecordAssigneeUserChange ¶
func (m *Manager) RecordAssigneeUserChange(conversationUUID string, assigneeID int, actor umodels.User) error
RecordAssigneeUserChange records an activity for a user assignee change.
func (*Manager) RecordPriorityChange ¶
RecordPriorityChange records an activity for a priority change.
func (*Manager) RecordSLASet ¶
RecordSLASet records an activity for an SLA set.
func (*Manager) RecordStatusChange ¶
RecordStatusChange records an activity for a status change.
func (*Manager) RecordTagAddition ¶
RecordTagAddition records an activity for a tag addition.
func (*Manager) RecordTagRemoval ¶
RecordTagRemoval records an activity for a tag removal.
func (*Manager) RemoveConversationAssignee ¶
RemoveConversationAssignee removes assigned user from a conversation.
func (*Manager) RenderMessageInTemplate ¶
RenderMessageInTemplate renders message content in template.
func (*Manager) Run ¶
func (m *Manager) Run(ctx context.Context, incomingQWorkers, outgoingQWorkers, scanInterval time.Duration)
Run starts a pool of worker goroutines to handle message dispatching via inbox's channel and processes incoming messages. It scans for pending outgoing messages at the specified read interval and pushes them to the outgoing queue to be sent.
func (*Manager) RunDraftCleaner ¶
RunDraftCleaner runs the draft cleanup routine every 2 hours.
func (*Manager) RunUnsnoozer ¶
RunUnsnoozer runs the conversation unsnoozer.
func (*Manager) SendCSATReply ¶
func (m *Manager) SendCSATReply(actorUserID int, conversation models.Conversation) error
SendCSATReply sends a CSAT reply message to a conversation.
func (*Manager) SendPrivateNote ¶
func (m *Manager) SendPrivateNote(media []mmodels.Media, senderID int, conversationUUID, content string, mentions []models.MentionInput) (models.Message, error)
SendPrivateNote inserts a private message in a conversation.
func (*Manager) SetConversationTags ¶
func (c *Manager) SetConversationTags(uuid string, action string, tagNames []string, actor umodels.User) error
SetConversationTags sets the tags associated with a conversation.
func (*Manager) UnassignOpen ¶
UnassignOpen unassigns all open conversations belonging to a user. i.e conversations without status `Closed` and `Resolved`.
func (*Manager) UpdateAssignee ¶
UpdateAssignee updates the assignee of a conversation.
func (*Manager) UpdateConversationCustomAttributes ¶
func (c *Manager) UpdateConversationCustomAttributes(uuid string, customAttributes map[string]any) error
UpdateConversationCustomAttributes updates the custom attributes of a conversation.
func (*Manager) UpdateConversationFirstReplyAt ¶
func (c *Manager) UpdateConversationFirstReplyAt(conversationUUID string, conversationID int, at time.Time) error
UpdateConversationFirstReplyAt updates the first reply timestamp for a conversation.
func (*Manager) UpdateConversationLastMessage ¶
func (c *Manager) UpdateConversationLastMessage(conversation int, conversationUUID, lastMessage, lastMessageSenderType, messageType string, private bool, lastMessageAt time.Time) error
UpdateConversationLastMessage updates the last message details for a conversation. Also conditionally updates last_interaction fields if messageType != 'activity' and !private.
func (*Manager) UpdateConversationLastReplyAt ¶
func (c *Manager) UpdateConversationLastReplyAt(conversationUUID string, conversationID int, at time.Time) error
UpdateConversationLastReplyAt updates the last reply timestamp for a conversation.
func (*Manager) UpdateConversationPriority ¶
func (c *Manager) UpdateConversationPriority(uuid string, priorityID int, priority string, actor umodels.User) error
UpdateConversationPriority updates the priority of a conversation.
func (*Manager) UpdateConversationStatus ¶
func (c *Manager) UpdateConversationStatus(uuid string, statusID int, status, snoozeDur string, actor umodels.User) error
UpdateConversationStatus updates the status of a conversation.
func (*Manager) UpdateConversationTeamAssignee ¶
UpdateConversationTeamAssignee sets the assignee of a conversation to a specific team and sets the assigned user id to NULL.
func (*Manager) UpdateConversationUserAssignee ¶
func (c *Manager) UpdateConversationUserAssignee(uuid string, assigneeID int, actor umodels.User) error
UpdateConversationUserAssignee sets the assignee of a conversation to a specifc user.
func (*Manager) UpdateConversationWaitingSince ¶
UpdateConversationWaitingSince updates the waiting since timestamp for a conversation.
func (*Manager) UpdateMessageStatus ¶
UpdateMessageStatus updates the status of a message.
func (*Manager) UpdateUserLastSeen ¶
UpdateUserLastSeen updates the last seen timestamp for a specific user on a conversation.
func (*Manager) UpsertConversationDraft ¶
func (m *Manager) UpsertConversationDraft(conversationID, userID int, content string, meta json.RawMessage) (models.ConversationDraft, error)
UpsertConversationDraft saves or updates a draft for a conversation.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package priority handles the management of conversation priorities.
|
Package priority handles the management of conversation priorities. |
|
Package status handles the management of conversation statuses.
|
Package status handles the management of conversation statuses. |