This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
[Issue] Lynts with replies cannot be deleted. #91
Comments
I remember someone talking about this in the discord before I haven't seen it for myself |
same issue (ignore the content lmao) firefox_LsSSbbbWai.mp4 |
The way that deleting posts works is kinda dumb From export async function deleteLynt(lyntId: string) {
await db.transaction(async (trx) => {
// Get all comments under this lynt
const comments = await trx.select({ id: lynts.id }).from(lynts).where(eq(lynts.parent, lyntId));
const commentIds = comments.map((comment) => comment.id);
const allIds = [lyntId, ...commentIds];
// Delete likes associated with the comments and the original lynt
await trx.delete(likes).where(inArray(likes.lynt_id, allIds));
// Delete notifications associated with the comments and the original lynt
await trx.delete(notifications).where(inArray(notifications.lyntId, allIds));
// Delete history entries associated with the comments and the original lynt
await trx.delete(history).where(inArray(history.lynt_id, allIds));
// Delete all comments under this lynt
await trx.delete(lynts).where(and(eq(lynts.parent, lyntId), eq(lynts.reposted, false)));
// Update reposts of this lynt
await trx
.update(lynts)
.set({
content: sql`${lynts.content} || '\nThe Lynt this user is reposting has been since deleted.'`,
parent: null
})
.where(and(eq(lynts.parent, lyntId), eq(lynts.reposted, true)));
// Delete the original lynt
await trx.delete(lynts).where(eq(lynts.id, lyntId));
});
} All this code could have been replaced with a few cascade delete, I'm pretty sure |
A lot of stuff in the codebase is pretty shit |
I can't play this video for some reason |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
A lynt with replies cannot be deleted and it'll error out with "An unknown error occured: 500"
The text was updated successfully, but these errors were encountered: