fix(external-objects): scope issue deletion activation

Select distinct company-owned mention object IDs before the issue cascade and notify only those objects. Preserve shared references and unrelated future inventory without company-wide reconstruction.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-30 21:46:27 -05:00
1 parent c2b8a6e05e
commit 18cf130c4e
3 files changed
+100 -3

No files matched your search

+9 -1
View File
@@ -97,6 +97,7 @@ import {
heartbeatRuns,
routineRuns,
executionWorkspaces,
externalObjectMentions,
issueApprovals,
issueAccessGrants,
issueAttachments,
@@ -12028,7 +12029,14 @@ export function issueService(db: Db) {
if (owner) {
await notifyIssueAttentionRetentionWork(tx, { companyId: owner.companyId, issueId: id });
await notifyExternalConversationSettlement(tx, { companyId: owner.companyId });
await notifyExternalObjectRefresh(tx, owner.companyId);
const mentionedObjects = await tx.selectDistinct({ objectId: externalObjectMentions.objectId })
.from(externalObjectMentions)
.where(and(
eq(externalObjectMentions.companyId, owner.companyId),
eq(externalObjectMentions.sourceIssueId, id),
isNotNull(externalObjectMentions.objectId),
));
for (const mention of mentionedObjects) await notifyExternalObjectRefresh(tx, owner.companyId, mention.objectId!);
await notifyApprovalWork(tx, owner.companyId);
await notifyStatusCardIssueChange(tx, owner.companyId);
}