-
-
Notifications
You must be signed in to change notification settings - Fork 703
MatrixRTC: Support the optional leave_reason in rtc membership content #5437
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
base: develop
Are you sure you want to change the base?
Changes from all commits
92707b2
c287dd9
5483987
bc0e6de
73085f8
9f7cad4
1124286
805f766
80f56fd
61d472a
ca54296
0511cb2
bcba2db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,8 @@ import { | |
| type IRTCDeclineContent, | ||
| type EncryptionKeysEventContent, | ||
| type ICallNotifyContent, | ||
| type LeaveMembershipEventContent, | ||
| type LeaveReason, | ||
| type RtcSlotEventContent, | ||
| } from "../matrixrtc/types.ts"; | ||
| import { type M_POLL_END, type M_POLL_START, type PollEndEventContent, type PollStartEventContent } from "./polls.ts"; | ||
|
|
@@ -361,7 +363,7 @@ export interface TimelineEvents { | |
| [M_BEACON.name]: MBeaconEventContent; | ||
| [M_POLL_START.name]: PollStartEventContent; | ||
| [M_POLL_END.name]: PollEndEventContent; | ||
| [EventType.RTCMembership]: RtcMembershipData | { msc4354_sticky_key: string }; // An object containing just the sticky key is empty. | ||
| [EventType.RTCMembership]: RtcMembershipData | { msc4354_sticky_key: string; leave_reason?: LeaveReason }; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -396,7 +398,11 @@ export interface StateEvents { | |
|
|
||
| // MSC3401 | ||
| [EventType.GroupCallPrefix]: IGroupCallRoomState; | ||
| [EventType.GroupCallMemberPrefix]: IGroupCallRoomMemberState | SessionMembershipData | EmptyObject; | ||
| [EventType.GroupCallMemberPrefix]: | ||
| | IGroupCallRoomMemberState | ||
| | SessionMembershipData | ||
| | LeaveMembershipEventContent | ||
| | EmptyObject; | ||
|
Comment on lines
+404
to
+405
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| [EventType.RTCMembership]: RtcMembershipData | EmptyObject; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, should this state event type still exist? (If so, should it also get a |
||
| [EventType.RTCSlot]: RtcSlotEventContent | EmptyObject; | ||
| // MSC3089 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,7 @@ import type { | |||||
| RTCCallIntent, | ||||||
| Transport, | ||||||
| SlotDescription, | ||||||
| LeaveReason, | ||||||
| RtcSlotEventContent, | ||||||
| } from "./types.ts"; | ||||||
| import { | ||||||
|
|
@@ -586,9 +587,15 @@ export class MatrixRTCSession extends TypedEventEmitter< | |||||
| * The membership update required to leave the session will retry if it fails. | ||||||
| * Without network connection the promise will never resolve. | ||||||
| * A timeout can be provided so that there is a guarantee for the promise to resolve. | ||||||
| * | ||||||
| * @param timeout - Optional timeout in milliseconds that fires if the leave takes too long to complete. | ||||||
| * @param leaveReason - The reason for the leave | ||||||
| * @returns Whether the membership update was attempted and did not time out. | ||||||
| */ | ||||||
| public async leaveRoomSession(timeout: number | undefined = undefined): Promise<boolean> { | ||||||
| public async leaveRoomSession( | ||||||
| timeout: number | undefined = undefined, | ||||||
| leaveReason: LeaveReason | undefined = undefined, | ||||||
| ): Promise<boolean> { | ||||||
| if (!this.isJoined()) { | ||||||
| this.logger.info(`Not joined to session in room ${this.roomSubset.roomId}: ignoring leave call`); | ||||||
| return false; | ||||||
|
|
@@ -598,7 +605,7 @@ export class MatrixRTCSession extends TypedEventEmitter< | |||||
|
|
||||||
| this.encryptionManager!.leave(); | ||||||
|
|
||||||
| const leavePromise = this.membershipManager!.leave(timeout); | ||||||
| const leavePromise = this.membershipManager!.leave(timeout, leaveReason); | ||||||
| this.emit(MatrixRTCSessionEvent.JoinStateChanged, false); | ||||||
|
|
||||||
| return await leavePromise; | ||||||
|
|
@@ -887,7 +894,7 @@ function quickFilterNonRelevantContents(content: IContent, logger: Logger): bool | |||||
| // Ignore sticky keys for the count | ||||||
| const eventKeysCount = Object.keys(content).filter((k) => k !== "msc4354_sticky_key").length; | ||||||
| // Don't even bother about empty events (saves us from costly type/"key in" checks in bigger rooms) | ||||||
| if (eventKeysCount === 0) return false; | ||||||
| if (eventKeysCount === 0 || (eventKeysCount === 1 && "leave_reason" in content)) return false; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
To account for the other keys that can be part of a |
||||||
|
|
||||||
| // We first decide if it's a MSC4143 event (per device state key) | ||||||
| if (eventKeysCount > 1 && "application" in content) { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be more properties in this variant, like
slot_idandmember?