From 98bf430604ae0976e9f200f6ddb3971ae18a8baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Fri, 19 Dec 2025 18:00:41 +0300 Subject: [PATCH] fix inbox: show badges in inbox --- app/routes/users.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/routes/users.py b/app/routes/users.py index 874320e..2c42ee1 100644 --- a/app/routes/users.py +++ b/app/routes/users.py @@ -645,12 +645,29 @@ def inbox(username): subscriptions ON subscriptions.thread_id = posts.thread_id WHERE subscriptions.user_id = ? AND posts.created_at > subscriptions.last_seen GROUP BY posts.thread_id + ), + user_badges AS ( + SELECT + b.user_id, + json_group_array( + json_object( + 'label', b.label, + 'link', b.link, + 'sort_order', b.sort_order, + 'file_path', bu.file_path + ) + ) AS badges_json + FROM badges b + LEFT JOIN badge_uploads bu ON b.upload = bu.id + GROUP BY b.user_id + ORDER BY b.sort_order ) SELECT tm.thread_id, tm.thread_slug, tm.thread_title, tm.unread_count, tm.newest_post_time, - posts.id, posts.created_at, post_history.content, post_history.edited_at, users.username, users.status, avatars.file_path AS avatar_path, posts.thread_id, users.id AS user_id, post_history.original_markup, users.signature_rendered + posts.id, posts.created_at, post_history.content, post_history.edited_at, users.username, users.status, avatars.file_path AS avatar_path, posts.thread_id, users.id AS user_id, post_history.original_markup, users.signature_rendered, + COALESCE(user_badges.badges_json, '[]') AS badges_json FROM thread_metadata tm JOIN @@ -665,6 +682,8 @@ def inbox(username): avatars ON users.avatar_id = avatars.id LEFT JOIN subscriptions ON subscriptions.thread_id = posts.thread_id + LEFT JOIN + user_badges ON users.id = user_badges.user_id WHERE subscriptions.user_id = ? AND posts.created_at > subscriptions.last_seen ORDER BY @@ -698,6 +717,7 @@ def inbox(username): 'user_id': row['user_id'], 'original_markup': row['original_markup'], 'signature_rendered': row['signature_rendered'], + 'badges_json': row['badges_json'], 'thread_slug': row['thread_slug'], })