mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 02:26:12 +02:00
Remove external mentions for deleted comments
This commit is contained in:
1 parent
5edfa628cd
commit
505e3afc2a
2 files changed
+28
-1
No files matched your search
@@ -529,6 +529,28 @@ describeEmbeddedPostgres("externalObjectService", () => {
|
||||
expect(resolve).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("removes comment mentions when a synced comment is hard-deleted", async () => {
|
||||
const { companyId, issueId } = await createIssue();
|
||||
const commentId = randomUUID();
|
||||
await db.insert(issueComments).values({
|
||||
id: commentId,
|
||||
companyId,
|
||||
issueId,
|
||||
authorType: "user",
|
||||
authorUserId: "local-board",
|
||||
body: "See https://github.com/acme/app/issues/88",
|
||||
});
|
||||
const svc = externalObjectService(db, { github: false });
|
||||
|
||||
await svc.syncComment(commentId);
|
||||
expect(await db.select().from(externalObjectMentions)).toHaveLength(1);
|
||||
|
||||
await db.delete(issueComments).where(eq(issueComments.id, commentId));
|
||||
await svc.syncComment(commentId);
|
||||
|
||||
expect(await db.select().from(externalObjectMentions)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("skips terminal objects when refreshing due objects", async () => {
|
||||
const { companyId, issueId } = await createIssue();
|
||||
const resolve = vi.fn(async () => ({
|
||||
|
||||
@@ -527,7 +527,12 @@ export function externalObjectService(
|
||||
.from(issueComments)
|
||||
.where(eq(issueComments.id, commentId))
|
||||
.then((rows: Array<{ id: string; companyId: string; issueId: string; body: string }>) => rows[0] ?? null);
|
||||
if (!comment) throw notFound("Issue comment not found");
|
||||
if (!comment) {
|
||||
await tx
|
||||
.delete(externalObjectMentions)
|
||||
.where(and(eq(externalObjectMentions.sourceKind, "comment"), eq(externalObjectMentions.sourceRecordId, commentId)));
|
||||
return;
|
||||
}
|
||||
await replaceSourceMentions({
|
||||
companyId: comment.companyId,
|
||||
sourceIssueId: comment.issueId,
|
||||
|
||||
Reference in new issue
Block a user