Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure protocolRole persists between requests #943

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/api/src/dwn-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ export class DwnApi {
*/
remoteOrigin : request.from,
delegateDid : this.delegateDid,
protocolRole : request.message.protocolRole,
...entry as DwnMessage[DwnInterface.RecordsWrite]
};
const record = new Record(this.agent, recordOptions, this.permissionsApi);
Expand Down Expand Up @@ -787,6 +788,7 @@ export class DwnApi {
* payload must be read again (e.g., if the data stream is consumed).
*/
remoteOrigin : request.from,
protocolRole : request.message.protocolRole,
delegateDid : this.delegateDid,
...responseRecord,
};
Expand Down Expand Up @@ -827,6 +829,7 @@ export class DwnApi {
connectedDid : this.connectedDid,
delegateDid : this.delegateDid,
permissionsApi : this.permissionsApi,
protocolRole : request.message.protocolRole,
request
})
};
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ export class Record implements RecordModel {
private async readRecordData({ target, isRemote }: { target: string, isRemote: boolean }) {
const readRequest: ProcessDwnRequest<DwnInterface.RecordsRead> = {
author : this._connectedDid,
messageParams : { filter: { recordId: this.id } },
messageParams : { filter: { recordId: this.id }, protocolRole: this._protocolRole },
messageType : DwnInterface.RecordsRead,
target,
};
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/subscription-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export class SubscriptionUtil {
/**
* Creates a record subscription handler that can be used to process incoming {Record} messages.
*/
static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, permissionsApi }:{
static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, protocolRole, permissionsApi }:{
agent: Web5Agent;
connectedDid: string;
delegateDid?: string;
protocolRole?: string;
permissionsApi?: PermissionsApi;
request: RecordsSubscribeRequest;
}): DwnRecordSubscriptionHandler {
Expand All @@ -31,6 +32,7 @@ export class SubscriptionUtil {
const record = new Record(agent, {
...message,
...recordOptions,
protocolRole,
delegateDid: delegateDid,
}, permissionsApi);

Expand Down
Loading