Skip to content

Commit 8bc042e

Browse files
committed
fix: requestAccessUpdate targetAccessName uses doctor's sharing access ID
Was using invite.checkAndGetAccessInfo() which returns patient-side access info (wrong username). Now uses the doctor's own sharing access ID to build the CC key that matches the patient-side CollectorClient.key.
1 parent 33c8dcc commit 8bc042e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

ts/appTemplates/Collector.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,15 @@ export class Collector {
362362
if (invite.status !== 'active') throw new HDSLibError(`Invite must be active to request update, current: ${invite.status}`);
363363

364364
// targetAccessName matches CollectorClient.key on the patient side
365-
// which is built from accessInfo: username + ':' + accessName
366-
const accessInfo = await invite.checkAndGetAccessInfo();
367-
if (!accessInfo) throw new HDSLibError('Cannot get access info for invite — may have been revoked');
368-
const targetAccessName = accessInfo.user.username + ':' + accessInfo.name;
365+
// CC key = doctorUsername + ':' + sharingAccessId (from the sharing access info stored in the CC event)
366+
const sharingAccessName = 'a-' + this.streamId;
367+
const [accesses, myAccessInfo] = await Promise.all([
368+
this.appManaging.connection.apiOne('accesses.get', {}, 'accesses'),
369+
this.appManaging.connection.accessInfo()
370+
]);
371+
const sharingAccess = accesses.find((a) => a.name === sharingAccessName);
372+
if (!sharingAccess) throw new HDSLibError('Cannot find sharing access for this collector');
373+
const targetAccessName = myAccessInfo.user.username + ':' + sharingAccess.id;
369374

370375
const eventData = {
371376
type: 'request/access-update-v1',

0 commit comments

Comments
 (0)