mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-23 02:53:32 +00:00
chore: set closed_at and resolved_at only once in conversations, on subsequent updates they are not to be updated again and again to the current time
- Remove unncessary websocket update due to this change
This commit is contained in:
@@ -574,13 +574,6 @@ func (c *Manager) UpdateConversationStatus(uuid string, statusID int, status, sn
|
||||
|
||||
// Broadcast updates using websocket.
|
||||
c.BroadcastConversationUpdate(uuid, "status", status)
|
||||
if status == models.StatusResolved {
|
||||
c.BroadcastConversationUpdate(uuid, "resolved_at", time.Now().Format(time.RFC3339))
|
||||
}
|
||||
if status == models.StatusClosed {
|
||||
c.BroadcastConversationUpdate(uuid, "closed_at", time.Now().Format(time.RFC3339))
|
||||
c.BroadcastConversationUpdate(uuid, "resolved_at", time.Now().Format(time.RFC3339))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -197,9 +197,9 @@ WHERE uuid = $1;
|
||||
-- name: update-conversation-status
|
||||
UPDATE conversations
|
||||
SET status_id = (SELECT id FROM conversation_statuses WHERE name = $2),
|
||||
resolved_at = CASE WHEN $2 IN ('Resolved', 'Closed') THEN NOW() ELSE resolved_at END,
|
||||
closed_at = CASE WHEN $2 = 'Closed' THEN NOW() ELSE closed_at END,
|
||||
snoozed_until = CASE WHEN $2 = 'Snoozed' THEN $3::timestamptz ELSE NULL END,
|
||||
resolved_at = COALESCE(resolved_at, CASE WHEN $2 IN ('Resolved', 'Closed') THEN NOW() END),
|
||||
closed_at = COALESCE(closed_at, CASE WHEN $2 = 'Closed' THEN NOW() END),
|
||||
snoozed_until = CASE WHEN $2 = 'Snoozed' THEN $3::timestamptz ELSE snoozed_until END,
|
||||
updated_at = NOW()
|
||||
WHERE uuid = $1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user