Skip to main content

max / makenotwork

multithreaded: filter removed posts out of the thread-list mention badge Fifth site in the removed_at/deleted_at drift class, found while working the escalation trigger (problem fd1c52ca). get_threads_with_mentions_for_user filtered neither column, so a mention inside a mod-removed post kept lighting the badge on the thread list at views.rs:297. Wrong today, not latent, and the same bug as the has_mention flag fixed in 7e0bef00.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-27 14:26 UTC
Signed with PGP, not checked
Commit: 327b35beff9d387f1b8e60b05248dc2891930bd7
Parent: 97fb193
3 files changed, +32 insertions, -25 deletions
@@ -1,6 +1,11 @@
1 1 use super::{PgPool, Uuid};
2 2
3 - /// Batch-check which threads have at least one mention of the given user.
3 + /// Batch-check which threads have at least one *live* mention of the given user.
4 + ///
5 + /// Removed and author-deleted posts do not count, matching the `has_mention`
6 + /// flag in `list_tracked_threads`. Both drive a badge that sends the reader to a
7 + /// thread to find the mention, and a badge naming content that is no longer
8 + /// there is worse than no badge.
4 9 #[tracing::instrument(skip_all)]
5 10 pub async fn get_threads_with_mentions_for_user(
6 11 pool: &PgPool,
@@ -15,7 +20,9 @@
15 20 FROM post_mentions pm
16 21 JOIN posts p ON p.id = pm.post_id
17 22 WHERE pm.mentioned_user_id = $1
18 - AND p.thread_id = ANY($2)",
23 + AND p.thread_id = ANY($2)
24 + AND p.removed_at IS NULL
25 + AND p.deleted_at IS NULL",
19 26 user_id,
20 27 thread_ids,
21 28 )
@@ -1,23 +1,0 @@
1 - {
2 - "db_name": "PostgreSQL",
3 - "query": "SELECT DISTINCT p.thread_id\n FROM post_mentions pm\n JOIN posts p ON p.id = pm.post_id\n WHERE pm.mentioned_user_id = $1\n AND p.thread_id = ANY($2)",
4 - "describe": {
5 - "columns": [
6 - {
7 - "ordinal": 0,
8 - "name": "thread_id",
9 - "type_info": "Uuid"
10 - }
11 - ],
12 - "parameters": {
13 - "Left": [
14 - "Uuid",
15 - "UuidArray"
16 - ]
17 - },
18 - "nullable": [
19 - false
20 - ]
21 - },
22 - "hash": "7c9f90b599e90aacd74a9f9384344ef4bae156fddde8e35888eb50e133cef4b5"
23 - }
@@ -1,0 +1,23 @@
1 + {
2 + "db_name": "PostgreSQL",
3 + "query": "SELECT DISTINCT p.thread_id\n FROM post_mentions pm\n JOIN posts p ON p.id = pm.post_id\n WHERE pm.mentioned_user_id = $1\n AND p.thread_id = ANY($2)\n AND p.removed_at IS NULL\n AND p.deleted_at IS NULL",
4 + "describe": {
5 + "columns": [
6 + {
7 + "ordinal": 0,
8 + "name": "thread_id",
9 + "type_info": "Uuid"
10 + }
11 + ],
12 + "parameters": {
13 + "Left": [
14 + "Uuid",
15 + "UuidArray"
16 + ]
17 + },
18 + "nullable": [
19 + false
20 + ]
21 + },
22 + "hash": "87b15b1d98934f0e170b87eed84e7f86e0fe289b9104555539c2d8f974aad4e9"
23 + }