mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-24 11:26:22 +00:00
9cd8aae3dc
- feat: show new messages in conversation count when user has scrolled to older messages - feat: Events in conversation update automation rules - feat: use prop vee-validate validations in `SelectTag` custom component and changes to enable use of vee-validate - Adds new column events in automation rules - Delete unlinked messages media files periodically.
50 lines
1.3 KiB
SQL
50 lines
1.3 KiB
SQL
-- name: insert-media
|
|
INSERT INTO media (store, filename, content_type, size, meta, model_id, model_type, disposition, content_id, uuid)
|
|
VALUES(
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
NULLIF($6, 0),
|
|
NULLIF($7, ''),
|
|
$8,
|
|
$9,
|
|
$10
|
|
)
|
|
RETURNING id;
|
|
|
|
-- name: get-media
|
|
SELECT id, created_at, "uuid", store, filename, content_type, model_id, model_type, "size", COALESCE(disposition, '') AS disposition
|
|
FROM media
|
|
WHERE id = $1;
|
|
|
|
-- name: get-media-by-uuid
|
|
SELECT id, created_at, "uuid", store, filename, content_type, model_id, model_type, "size", COALESCE(disposition, '') AS disposition
|
|
FROM media
|
|
WHERE uuid = $1;
|
|
|
|
-- name: delete-media
|
|
DELETE FROM media
|
|
WHERE uuid = $1;
|
|
|
|
-- name: attach-to-model
|
|
UPDATE media
|
|
SET model_type = $2,
|
|
model_id = $3
|
|
WHERE id = $1;
|
|
|
|
-- name: get-model-media
|
|
SELECT id, created_at, "uuid", store, filename, content_type, model_id, model_type, "size", COALESCE(disposition, '') AS disposition
|
|
FROM media
|
|
WHERE model_type = $1
|
|
AND model_id = $2;
|
|
|
|
-- name: get-unlinked-message-media
|
|
SELECT id, created_at, "uuid", store, filename, content_type, model_id, model_type, "size", COALESCE(disposition, '') AS disposition
|
|
FROM media
|
|
WHERE model_type = 'messages'
|
|
AND model_id IS NULL or model_id = 0 AND created_at < NOW() - INTERVAL '1 day';
|
|
|
|
-- name: content-id-exists
|
|
SELECT EXISTS(SELECT 1 FROM media WHERE content_id = $1); |