From 708594d32ffe779cf547c816fa7cdd19d095be2e Mon Sep 17 00:00:00 2001
From: Freya Murphy <freya@freyacat.org>
Date: Mon, 20 May 2024 17:11:38 -0400
Subject: v2 done

---
 src/db/rest/user/api_user.sql | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

(limited to 'src/db/rest/user/api_user.sql')

diff --git a/src/db/rest/user/api_user.sql b/src/db/rest/user/api_user.sql
index d71fd1b..0660f42 100644
--- a/src/db/rest/user/api_user.sql
+++ b/src/db/rest/user/api_user.sql
@@ -23,7 +23,11 @@ CREATE VIEW api.user AS
 		COALESCE(p.pc, 0)
 			AS post_count,
 		COALESCE(l.lc, 0)
-			AS like_count
+			AS like_count,
+		ma.mime
+			AS avatar_mime,
+		mb.mime
+			AS banner_mime
 	FROM
 		admin.user u
 	LEFT JOIN (
@@ -81,6 +85,28 @@ CREATE VIEW api.user AS
 	) l
 	ON
 		u.id = l.user_id
+	LEFT JOIN (
+		SELECT
+			ma.mime,
+			ma.user_id
+		FROM
+			admin.user_media ma
+		WHERE
+			ma.type = 'avatar'
+	) ma
+	ON
+		u.id = ma.user_id
+	LEFT JOIN (
+		SELECT
+			mb.mime,
+			mb.user_id
+		FROM
+			admin.user_media mb
+		WHERE
+			mb.type = 'banner'
+	) mb
+	ON
+		u.id = mb.user_id
 	WHERE
 		u.deleted <> TRUE;
 
-- 
cgit v1.2.3-freya

