sse bug fix

This commit is contained in:
2025-02-04 13:19:05 +05:30
parent 6a57fed0dc
commit 9f337655a0
4 changed files with 61 additions and 44 deletions

View File

@@ -16,12 +16,15 @@ export async function createOrg(input: CreateOrgInput, tenantId: string) {
...input,
});
dbEvents.emit("change", {
type: "insert",
collection: "orgs",
document: org,
requiredClaims: ["org:read"],
} as ChangeEvent);
dbEvents.emit(
"change",
{
type: "insert",
collection: "orgs",
document: org,
} as ChangeEvent,
["org:read"]
);
return org;
}
@@ -79,12 +82,15 @@ export async function updateOrg(
);
if (updateOrgResult) {
dbEvents.emit("change", {
type: "update",
collection: "orgs",
document: updateOrgResult,
requiredClaims: ["org:read"],
} as ChangeEvent);
dbEvents.emit(
"change",
{
type: "update",
collection: "orgs",
document: updateOrgResult,
} as ChangeEvent,
["org:read"]
);
}
return updateOrgResult;
@@ -96,14 +102,17 @@ export async function deleteOrg(orgId: string, tenantId: string) {
});
if (res.deletedCount > 0) {
dbEvents.emit("change", {
type: "delete",
collection: "orgs",
document: {
pid: orgId,
},
requiredClaims: ["org:read"],
} as ChangeEvent);
dbEvents.emit(
"change",
{
type: "delete",
collection: "orgs",
document: {
pid: orgId,
},
} as ChangeEvent,
["org:read"]
);
}
return res;