Skip to content

Commit 0170242

Browse files
dahliaclaude
andcommitted
Fix poll expiry notifications not showing up
The poll notification query was incorrectly joining with accountOwners, which filtered out polls from remote users. This meant users wouldn't receive notifications for expired polls they had voted on if the poll was created by a remote user. Fixed by: - Removing the unnecessary INNER JOIN with accountOwners table - Checking posts.accountId = owner.id directly for author check - Checking pollVotes.accountId = owner.id directly for voter check Now users receive poll expiry notifications for: - Polls they authored (local polls) - Polls they voted on (including remote polls) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9b8b069 commit 0170242

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/api/v1/notifications.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ import {
1313
tokenRequired,
1414
type Variables,
1515
} from "../../oauth/middleware";
16-
import {
17-
accountOwners,
18-
notifications,
19-
polls,
20-
pollVotes,
21-
posts,
22-
} from "../../schema";
16+
import { notifications, polls, pollVotes, posts } from "../../schema";
2317
import type { Uuid } from "../../uuid";
2418

2519
const logger = getLogger(["hollo", "notifications"]);
@@ -210,23 +204,23 @@ app.get(
210204
}
211205

212206
// Find expired polls where user is the author or has voted
207+
// Note: We don't join with accountOwners here because that would filter out
208+
// polls from remote users. Instead, we check the conditions directly.
213209
const expiredPollIds = await db
214210
.selectDistinct({ pollId: polls.id, expires: polls.expires })
215211
.from(polls)
216212
.innerJoin(posts, eq(posts.pollId, polls.id))
217-
.innerJoin(accountOwners, eq(posts.accountId, accountOwners.id))
218213
.where(
219214
and(
220215
lte(polls.expires, now),
221216
or(
222-
// User is the post author
223-
eq(accountOwners.id, owner.id),
217+
// User is the post author (owner.id equals the account ID)
218+
eq(posts.accountId, owner.id),
224219
// User has voted in the poll
225220
sql`EXISTS (
226221
SELECT 1 FROM ${pollVotes}
227-
INNER JOIN ${accountOwners} AS voter_owner ON ${pollVotes.accountId} = voter_owner.id
228222
WHERE ${pollVotes.pollId} = ${polls.id}
229-
AND voter_owner.id = ${owner.id}
223+
AND ${pollVotes.accountId} = ${owner.id}
230224
)`,
231225
),
232226
...pollPaginationConditions,

0 commit comments

Comments
 (0)