client: fix 500 error in notifications

closes FoundKeyGang/FoundKey#73

Changelog: Fixed
This commit is contained in:
Johann150 2023-01-01 23:32:01 +01:00
parent 3aaa9facc6
commit 0fbd7fa492
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -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);