mirror of
https://github.com/abhinavxd/libredesk.git
synced 2025-10-23 05:11:57 +00:00
- 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.
72 lines
1013 B
SQL
72 lines
1013 B
SQL
-- name: get
|
|
SELECT
|
|
id,
|
|
created_at,
|
|
updated_at,
|
|
name,
|
|
actions,
|
|
visibility,
|
|
visible_when,
|
|
message_content,
|
|
user_id,
|
|
team_id,
|
|
usage_count
|
|
FROM
|
|
macros
|
|
WHERE
|
|
id = $1;
|
|
|
|
-- name: get-all
|
|
SELECT
|
|
id,
|
|
created_at,
|
|
updated_at,
|
|
name,
|
|
actions,
|
|
visibility,
|
|
visible_when,
|
|
message_content,
|
|
user_id,
|
|
team_id,
|
|
usage_count
|
|
FROM
|
|
macros
|
|
ORDER BY
|
|
updated_at DESC;
|
|
|
|
-- name: create
|
|
INSERT INTO
|
|
macros (name, message_content, user_id, team_id, visibility, visible_when, actions)
|
|
VALUES
|
|
($1, $2, $3, $4, $5, $6, $7)
|
|
RETURNING *;
|
|
|
|
-- name: update
|
|
UPDATE
|
|
macros
|
|
SET
|
|
name = $2,
|
|
message_content = $3,
|
|
user_id = $4,
|
|
team_id = $5,
|
|
visibility = $6,
|
|
visible_when = $7,
|
|
actions = $8,
|
|
updated_at = NOW()
|
|
WHERE
|
|
id = $1
|
|
RETURNING *;
|
|
|
|
-- name: delete
|
|
DELETE FROM
|
|
macros
|
|
WHERE
|
|
id = $1;
|
|
|
|
-- name: increment-usage-count
|
|
UPDATE
|
|
macros
|
|
SET
|
|
usage_count = usage_count + 1
|
|
WHERE
|
|
id = $1; |