Skip to content

Commit 97e6286

Browse files
committed
fix: regression on registry participants array
1 parent 3e22b87 commit 97e6286

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

infrastructure/evault-core/src/core/db/db.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,28 @@ export class DbService {
665665
// field on the meta-envelope (e.g. wiping participantIds when
666666
// a read-receipt update arrives).
667667

668+
// Build the full post-write state by merging the pre-write
669+
// envelope set with everything we just wrote. Used by
670+
// resolvers to fan out webhooks containing the complete
671+
// merged state — receivers overwrite their local row with
672+
// whatever the webhook carries, so a partial diff would
673+
// make them lose every untouched field.
674+
const mergedPayload: Record<string, any> = {};
675+
for (const env of workingEnvelopes) {
676+
mergedPayload[env.ontology] = env.value;
677+
}
678+
for (const env of createdEnvelopes) {
679+
mergedPayload[env.ontology] = env.value;
680+
}
681+
668682
return {
669683
metaEnvelope: {
670684
id,
671685
ontology: meta.ontology,
672686
acl,
673687
},
674688
envelopes: createdEnvelopes,
689+
mergedPayload,
675690
};
676691
});
677692
} catch (error) {

infrastructure/evault-core/src/core/db/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export type MetaEnvelopeResult<
3737

3838
/**
3939
* Result type for storing a new meta-envelope.
40+
*
41+
* `envelopes` are the envelopes touched by this operation. `mergedPayload`,
42+
* when present, is the FULL post-write state of the meta-envelope (every
43+
* field, not just the touched ones) — used by callers that need to fan out
44+
* a webhook with the complete merged state rather than the partial diff.
4045
*/
4146
export type StoreMetaEnvelopeResult<
4247
T extends Record<string, any> = Record<string, any>
@@ -47,6 +52,7 @@ export type StoreMetaEnvelopeResult<
4752
acl: string[];
4853
};
4954
envelopes: Envelope<T[keyof T]>[];
55+
mergedPayload?: Record<string, any>;
5056
};
5157

5258
/**

infrastructure/evault-core/src/core/protocol/graphql-server.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,21 @@ export class GraphQLServer {
530530
parsed: parsedFromEnvelopes,
531531
};
532532

533-
// Deliver webhooks for update operation
533+
// Deliver webhooks for update operation.
534+
// Use the FULL post-write state, not input.payload —
535+
// input.payload is the partial diff the caller sent,
536+
// and receivers overwrite their local row with
537+
// whatever the webhook carries. Sending the diff
538+
// would make the receiver lose every untouched
539+
// field (e.g. a read-receipt update would wipe
540+
// participantIds on the receiver side).
534541
const requestingPlatform =
535542
context.tokenPayload?.platform || null;
536543
const webhookPayload = {
537544
id,
538545
w3id: context.eName,
539546
evaultPublicKey: this.evaultPublicKey,
540-
data: input.payload,
547+
data: result.mergedPayload ?? input.payload,
541548
schemaId: input.ontology,
542549
};
543550

@@ -1222,14 +1229,18 @@ export class GraphQLServer {
12221229
context.eName,
12231230
);
12241231

1225-
// Deliver webhooks for update operation
1232+
// Deliver webhooks with the FULL post-write state.
1233+
// See the long comment on the new updateMetaEnvelope
1234+
// resolver above — sending input.payload (the
1235+
// partial diff) would make receivers clobber their
1236+
// own untouched fields.
12261237
const requestingPlatform =
12271238
context.tokenPayload?.platform || null;
12281239
const webhookPayload = {
12291240
id: id,
12301241
w3id: context.eName,
12311242
evaultPublicKey: this.evaultPublicKey,
1232-
data: input.payload,
1243+
data: result.mergedPayload ?? input.payload,
12331244
schemaId: input.ontology,
12341245
};
12351246

0 commit comments

Comments
 (0)