From 9ed46c335d6020b10f720d9738b8252d424dd24c Mon Sep 17 00:00:00 2001
From: Freya Murphy <freya@freyacat.org>
Date: Mon, 1 Apr 2024 15:02:51 -0400
Subject: start custom banner and avatar loading

---
 src/db/rest/util/_api_serve_media.sql | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'src/db/rest/util/_api_serve_media.sql')

diff --git a/src/db/rest/util/_api_serve_media.sql b/src/db/rest/util/_api_serve_media.sql
index 8b0f0b8..c2e213a 100644
--- a/src/db/rest/util/_api_serve_media.sql
+++ b/src/db/rest/util/_api_serve_media.sql
@@ -1,5 +1,5 @@
 CREATE FUNCTION _api.serve_media(
-	_name TEXT
+	_media_id INTEGER
 )
 RETURNS sys."*/*"
 LANGUAGE plpgsql VOLATILE
@@ -15,13 +15,13 @@ BEGIN
        '{"Cache-Control": "max-age=259200"}]'
       ,	m.type, m.name)
 	FROM admin.media m
-	WHERE m.name = _name INTO _headers;
+	WHERE m.id = _media_id INTO _headers;
 
 	PERFORM SET_CONFIG('response.headers', _headers, true);
 
 	SELECT m.content
 	FROM admin.media m
-	WHERE m.name = _name
+	WHERE m.id = _media_id
 	INTO _data;
 
 	IF FOUND THEN
@@ -35,7 +35,7 @@ BEGIN
 END
 $BODY$;
 
-GRANT EXECUTE ON FUNCTION _api.serve_media(TEXT)
+GRANT EXECUTE ON FUNCTION _api.serve_media(INTEGER)
 	TO rest_anon, rest_user;
 GRANT SELECT ON TABLE admin.media
 	TO rest_anon, rest_user;
-- 
cgit v1.2.3-freya

