Redact deleted issue comments

This commit is contained in:
Dotta
2026-06-03 17:32:25 +00:00
parent 78dc3625ac
commit 7f70759e61
27 changed files with 20722 additions and 83 deletions
+10 -2
View File
@@ -221,10 +221,11 @@ export function issueReferenceService(db: Db) {
companyId: issueComments.companyId,
issueId: issueComments.issueId,
body: issueComments.body,
deletedAt: issueComments.deletedAt,
})
.from(issueComments)
.where(eq(issueComments.id, commentId))
.then((rows: Array<{ id: string; companyId: string; issueId: string; body: string }>) => rows[0] ?? null);
.then((rows: Array<{ id: string; companyId: string; issueId: string; body: string; deletedAt: Date | null }>) => rows[0] ?? null);
if (!comment) throw notFound("Issue comment not found");
await replaceSourceMentions({
@@ -233,7 +234,7 @@ export function issueReferenceService(db: Db) {
sourceKind: "comment",
sourceRecordId: comment.id,
documentKey: null,
text: comment.body,
text: comment.deletedAt ? null : comment.body,
}, dbOrTx);
}
@@ -297,6 +298,12 @@ export function issueReferenceService(db: Db) {
.where(and(eq(issueReferenceMentions.sourceKind, "document"), eq(issueReferenceMentions.sourceRecordId, documentId)));
}
async function deleteCommentSource(commentId: string, dbOrTx: any = db) {
await dbOrTx
.delete(issueReferenceMentions)
.where(and(eq(issueReferenceMentions.sourceKind, "comment"), eq(issueReferenceMentions.sourceRecordId, commentId)));
}
async function syncAllForIssue(issueId: string, dbOrTx: any = db) {
const issue = await issueById(issueId, dbOrTx);
if (!issue) throw notFound("Issue not found");
@@ -429,6 +436,7 @@ export function issueReferenceService(db: Db) {
syncAnnotationComment,
syncDocument,
deleteDocumentSource,
deleteCommentSource,
syncAllForIssue,
syncAllForCompany,
listIssueReferenceSummary,