From 0fbd7fa4925a09f77ef16f5b433422502a6b67de Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sun, 1 Jan 2023 23:32:01 +0100 Subject: [PATCH] client: fix 500 error in notifications closes https://akkoma.dev/FoundKeyGang/FoundKey/issues/73 Changelog: Fixed --- packages/backend/src/services/following/delete.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/services/following/delete.ts b/packages/backend/src/services/following/delete.ts index 23cd7486e..9a29d1921 100644 --- a/packages/backend/src/services/following/delete.ts +++ b/packages/backend/src/services/following/delete.ts @@ -1,3 +1,4 @@ +import { db } from '@/db/postgre.js'; import { publishMainStream, publishUserEvent } from '@/services/stream.js'; import { renderActivity } from '@/remote/activitypub/renderer/index.js'; import renderFollow from '@/remote/activitypub/renderer/follow.js'; @@ -24,7 +25,11 @@ export default async function(follower: { id: User['id']; host: User['host']; ur return; } - await Followings.delete(following.id); + await Promise.all([ + Followings.delete(following.id), + // delete notifications that the ex-follower can now no longer see + db.query('DELETE FROM "notification" WHERE "noteId" IS NOT NULL AND "notifieeId" = $1 AND NOT note_visible("noteId", "notifieeId")', [follower.id]), + ]); decrementFollowing(follower, followee);