Skip to content

Commit b94e83b

Browse files
committed
deprecate membershipID -> memberId & memberId -> stateKey in membership
manager The membership manager used the memberId label for the stateKey. But only the StickymembershipManager really has a configurable memberId.
1 parent 0c6fb51 commit b94e83b

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/matrixrtc/CallMembership.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,26 @@ export class CallMembership {
407407
* value (used until version 0.16.0)
408408
*
409409
* It is also possible for a session event to set a custom membershipID. in that case this will be used.
410+
*
411+
* @deprecated renamed to `memberId`
410412
*/
411413
public get membershipID(): string {
414+
return this.memberId;
415+
}
416+
417+
/**
418+
* This computes the membership ID for the membership.
419+
* for the sticky event based rtcSessionData this is trivial it is `member.id`.
420+
*
421+
* For the legacy sessionMemberEvents it is a bit more complex. Here we sometimes do not have this data
422+
* in the event content and we expected the SFU and the client to use `${this.matrixEventData.sender}:${data.device_id}`.
423+
*
424+
* So if there is no membershipID we use the hard coded jwt id default (`${this.matrixEventData.sender}:${data.device_id}`)
425+
* value (used until version 0.16.0)
426+
*
427+
* It is also possible for a session event to set a custom membershipID. in that case this will be used.
428+
*/
429+
public get memberId(): string {
412430
// the createdTs behaves equivalent to the membershipID.
413431
// we only need the field for the legacy member events where we needed to update them
414432
// synapse ignores sending state events if they have the same content.

src/matrixrtc/MatrixRTCSession.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ export class MatrixRTCSession extends TypedEventEmitter<
593593
multiSfuFocus?: Transport,
594594
joinConfig?: JoinSessionConfig,
595595
): void {
596+
const [userId, deviceId] = [this.client.getUserId()!, this.client.getDeviceId()!];
597+
// TODO this wants to become a UUID
598+
const memberId = `${userId}:${deviceId}`;
596599
if (this.isJoined()) {
597600
this.logger.info(`Already joined to session in room ${this.roomSubset.roomId}: ignoring join call`);
598601
return;
@@ -604,6 +607,7 @@ export class MatrixRTCSession extends TypedEventEmitter<
604607
this.roomSubset,
605608
this.client,
606609
this.slotDescription,
610+
memberId,
607611
this.logger,
608612
)
609613
: new MembershipManager(joinConfig, this.roomSubset, this.client, this.slotDescription, this.logger);

src/matrixrtc/MembershipManager.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export class MembershipManager
336336
this.userId = userId;
337337
// this needs to become a uuid so that consecutive join/leaves result in a key rotation.
338338
// we keep it as a string for now for backwards compatibility.
339-
this.memberId = this.makeMembershipStateKey(userId, deviceId);
339+
this.stateKey = this.makeMembershipStateKey(userId, deviceId);
340340
this.state = MembershipManager.defaultState;
341341
this.callIntent = joinConfig?.callIntent;
342342
this.scheduler = new ActionScheduler((type): Promise<ActionUpdate> => {
@@ -383,7 +383,7 @@ export class MembershipManager
383383
// Membership Event static parameters:
384384
protected deviceId: string;
385385
protected userId: string;
386-
protected memberId: string;
386+
protected stateKey: string;
387387
protected rtcTransport?: Transport;
388388
/** @deprecated This will be removed in favor or rtcTransport becoming a list of actively used transports */
389389
private fociPreferred?: Transport[];
@@ -484,7 +484,7 @@ export class MembershipManager
484484
{ delay: this.delayedLeaveEventDelayMs },
485485
EventType.GroupCallMemberPrefix,
486486
{},
487-
this.memberId,
487+
this.stateKey,
488488
);
489489

490490
// HANDLERS (used in the membershipLoopHandler)
@@ -677,7 +677,7 @@ export class MembershipManager
677677
this.room.roomId,
678678
EventType.GroupCallMemberPrefix,
679679
myMembership as EmptyObject | SessionMembershipData,
680-
this.memberId,
680+
this.stateKey,
681681
);
682682
};
683683

@@ -1040,6 +1040,9 @@ export class StickyEventMembershipManager extends MembershipManager {
10401040
private readonly clientWithSticky: MembershipManagerClient &
10411041
Pick<MatrixClient, "_unstable_sendStickyEvent" | "_unstable_sendStickyDelayedEvent">,
10421042
sessionDescription: SlotDescription,
1043+
// this needs to become a uuid so that consecutive join/leaves result in a key rotation.
1044+
// we keep it as a string for now for backwards compatibility.
1045+
private readonly memberId: string,
10431046
parentLogger?: Logger,
10441047
) {
10451048
super(joinConfig, room, clientWithSticky, sessionDescription, parentLogger);

0 commit comments

Comments
 (0)