mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-21 10:03:23 +00:00
634fc66e9f
- Update all SQL queries to add missing columns - Update the create conversation API to allow setting the initiator of a conversation. For example, we might want to use this API to create a conversation on behalf of a customer, with the first message coming from the customer instead of the agent. This param allows this. - Minor refactors and clean up - Tidy go.mod - Rename structs to reflect purpose - Create focus structs for scanning JSON payloads for clarity.
29 lines
1.1 KiB
SQL
29 lines
1.1 KiB
SQL
-- name: get-active-inboxes
|
|
SELECT id, created_at, updated_at, "name", deleted_at, channel, enabled, csat_enabled, config, "from" FROM inboxes where enabled is TRUE and deleted_at is NULL;
|
|
|
|
-- name: get-all-inboxes
|
|
SELECT id, created_at, updated_at, "name", deleted_at, channel, enabled, csat_enabled, config, "from" FROM inboxes where deleted_at is NULL;
|
|
|
|
-- name: insert-inbox
|
|
INSERT INTO inboxes
|
|
(channel, config, "name", "from", csat_enabled)
|
|
VALUES($1, $2, $3, $4, $5)
|
|
RETURNING *
|
|
|
|
-- name: get-inbox
|
|
SELECT id, created_at, updated_at, "name", deleted_at, channel, enabled, csat_enabled, config, "from" FROM inboxes where id = $1 and deleted_at is NULL;
|
|
|
|
-- name: update
|
|
UPDATE inboxes
|
|
set channel = $2, config = $3, "name" = $4, "from" = $5, csat_enabled = $6, enabled = $7, updated_at = now()
|
|
where id = $1 and deleted_at is NULL
|
|
RETURNING *;
|
|
|
|
-- name: soft-delete
|
|
UPDATE inboxes set deleted_at = now(), updated_at = now(), config = '{}' where id = $1 and deleted_at is NULL;
|
|
|
|
-- name: toggle
|
|
UPDATE inboxes
|
|
SET enabled = NOT enabled, updated_at = NOW()
|
|
WHERE id = $1
|
|
RETURNING *; |