-
-
Notifications
You must be signed in to change notification settings - Fork 671
Switch sliding sync support to simplified sliding sync #4400
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
Merged
Changes from 10 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
65762c4
Switch sliding sync support to simplified sliding sync
dbkr 2593998
Remove txn_id handling, ensure we always resend when req params change
kegsay 6fba79c
Fix some tests
kegsay e26e926
Fix remaining tests
kegsay c75c06a
Mark TODOs on tests which need to die
kegsay 7444094
Linting
kegsay bf7be48
Make comments lie less
kegsay ade2c86
void
kegsay b8c3419
Always sent full extension request
kegsay 85400e9
Fix test
kegsay c44818f
Remove usage of deprecated field
kegsay aeeb25f
Hopefully fix DM names
kegsay 244ca62
Refactor how heroes are handled in Room
kegsay bd3f9f7
Fix how heroes work
kegsay 581b419
Linting
kegsay 39b4e9d
Ensure that when SSS omits heroes we don't forget we had heroes
kegsay 11e7a3d
Check the right flag when doing timeline trickling
kegsay 511a873
Also change when the backpagination token is set
kegsay 181d786
Remove list ops and server-provided sort positions
kegsay 679a984
Linting
kegsay cf37e43
Add Room.bumpStamp
kegsay 426aa93
Update crypto wasm lib
kegsay 63a636f
Add performance logging
kegsay f8d4161
Fix breaking change in crypto wasm v8
kegsay 1fd6675
Update crypto wasm for breaking changes
kegsay 8616294
Mark all tracked users as dirty on expired SSS connections
kegsay 3833273
Merge remote-tracking branch 'origin/develop' into dbkr/sss
dbkr 8b7213b
add ts extension
dbkr c6f8440
Fix typedoc ref
dbkr 336797e
Add method to interface
dbkr af846e7
Merge branch 'develop' into dbkr/sss
dbkr ec83c14
Don't force membership to invite
dbkr a75a263
Merge branch 'develop' into dbkr/sss
dbkr dec2cb0
Missed merge
dbkr 1634b83
Type import
dbkr ebef4cd
Make coverage happier
dbkr ef87316
More test coverage
dbkr 1dc3b4c
Merge branch 'develop' into dbkr/sss
dbkr f1d53cf
Grammar & formatting
dbkr 4ece850
Remove markAllTrackedUsersAsDirty from crypto API
dbkr 60f7bca
Remove I from interface
dbkr 7954040
API doc
dbkr 1d020df
Move Hero definition to room-summary
dbkr cc6ad7f
make comment more specific
dbkr e4527b5
Move internal details into room.ts
dbkr 42099bb
Use terser arrow function syntax
dbkr 38467e6
Move comment to where we do the lookup
dbkr ff25912
Clarify comment
dbkr 26069c9
Add comment
dbkr de7c5ea
Add tsdoc
dbkr 8a26967
more comment
dbkr a7d013f
Remove unrelated changes
dbkr 7028a88
Add docs & make fields optional
dbkr ee0219e
Type import
dbkr eeffb20
Merge branch 'develop' into dbkr/sss
dbkr d55a9ea
Clarify sync versions
dbkr 6ea801b
Make tsdoc comment & add info on when it's used.
dbkr 5a30e34
Rephrase comment
dbkr 8ca0c04
Prettier
dbkr 7506df2
Only fetch member for hero in legacy sync mode
dbkr 7d8aeee
Split out a separate method to set SSS room summary
dbkr 54492a8
Type import
dbkr 793ae01
Make link work
dbkr d793a10
Nope, linter treats it as an unused import
dbkr 7cca95a
Add link the other way
dbkr 085a2d4
Add more detail to doc
dbkr bd6ba39
Remove unnecessary cast
dbkr 7e1eb16
Remove length > 0 check
dbkr 5c44bbb
Doc params
dbkr 5f0b2e3
Remove unnecessary undefined comparison
dbkr 0030998
Put the comparison back
dbkr 707a7f5
Fix comment
dbkr 532d885
Fix comment
dbkr 06b0fd4
Merge branch 'develop' into dbkr/sss
dbkr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ import { | |
| } from "./event.ts"; | ||
| import { EventStatus } from "./event-status.ts"; | ||
| import { RoomMember } from "./room-member.ts"; | ||
| import { type IRoomSummary, type RoomSummaryMSC4186, type Hero, RoomSummary } from "./room-summary.ts"; | ||
| import { type IRoomSummary, type Hero, RoomSummary } from "./room-summary.ts"; | ||
| import { logger } from "../logger.ts"; | ||
| import { TypedReEmitter } from "../ReEmitter.ts"; | ||
| import { | ||
|
|
@@ -77,6 +77,7 @@ import { compareEventOrdering } from "./compare-event-ordering.ts"; | |
| import * as utils from "../utils.ts"; | ||
| import { KnownMembership, type Membership } from "../@types/membership.ts"; | ||
| import { type Capabilities, type IRoomVersionsCapability, RoomVersionStability } from "../serverCapabilities.ts"; | ||
| import { type MSC4186Hero } from "../sliding-sync.ts"; | ||
|
|
||
| // These constants are used as sane defaults when the homeserver doesn't support | ||
| // the m.room_versions capability. In practice, KNOWN_SAFE_ROOM_VERSION should be | ||
|
|
@@ -362,8 +363,15 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> { | |
| // read by megolm via getter; boolean value - null indicates "use global value" | ||
| private blacklistUnverifiedDevices?: boolean; | ||
| private selfMembership?: Membership; | ||
| // A Hero is a stripped m.room.member event which contains the key renderable fields from the event. | ||
| // It is used in MSC4186 (Simplified Sliding Sync) as a replacement for the old 'summary' field. | ||
| /** | ||
| * A `Hero` is a stripped `m.room.member` event which contains the important renderable fields from the event. | ||
| * | ||
| * It is used in MSC4186 (Simplified Sliding Sync) as a replacement for the old `summary` field. | ||
| * | ||
| * When we are doing old-style (`/v3/sync`) sync, we simulate the SSS behaviour by constructing | ||
| * a `Hero` object based on the user id we get from the summary. Obviously, in that case, | ||
| * the `Hero` will lack a `displayName` or `avatarUrl`. | ||
| */ | ||
| private heroes: Hero[] | null = null; | ||
| // flags to stop logspam about missing m.room.create events | ||
| private getTypeWarning = false; | ||
|
|
@@ -949,13 +957,9 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> { | |
| // use first hero that has a display name or avatar url, or whose user ID | ||
| // can be looked up as a member of the room | ||
| for (const hero of nonFunctionalHeroes) { | ||
| // The old form of heroes simply contained the hero's user ID, which forced clients to then look up the | ||
| // m.room.member event in the current state. This is entirely decoupled in SSS. To ensure this | ||
| // works in a backwards compatible way, we will A) only set displayName/avatarUrl with server-provided | ||
| // values, B) always prefer the hero values if they are set, over calling `.getMember`. This means | ||
| // in SSS mode we will use the heroes if the display name or avatar URL fields are set, but in sync v2 | ||
| // mode these fields will never be set and hence we will always do getMember lookups (at the right time as well). | ||
| if (!hero.displayName && !hero.avatarUrl) { | ||
| // If the hero was from a legacy sync (`/v3/sync`), we will need to look the user ID up in the room | ||
| // the display name and avatar URL will not be set. | ||
| if (!hero.fromMSC4186) { | ||
| // attempt to look up renderable fields from the m.room.member event if it exists | ||
richvdh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const member = this.getMember(hero.userId); | ||
| if (member) { | ||
|
|
@@ -1675,15 +1679,12 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> { | |
| } | ||
|
|
||
| /** | ||
| * Takes either a legacy or MSC4186 room summary and updates the room with it. | ||
| * The summary will be converted to a legacy style summary in order to be emitted | ||
| * in the `RoomEvent.Summary` event. | ||
| * Takes a legacy room summary (/v3/sync as opposed to MSC4186) and updates the room with it. | ||
| * | ||
| * @param summary - The room summary to update the room with | ||
| */ | ||
| public setSummary(summary: IRoomSummary | RoomSummaryMSC4186): void { | ||
| // map heroes onto the MSC4186 form as that has more data | ||
| const heroes = summary["m.heroes"]?.map((h) => (typeof h === "string" ? { userId: h } : h)); | ||
| public setSummary(summary: IRoomSummary): void { | ||
| const heroes = summary["m.heroes"]?.map((h) => ({ userId: h, fromMSC4186: false })); | ||
| const joinedCount = summary["m.joined_member_count"]; | ||
| const invitedCount = summary["m.invited_member_count"]; | ||
| if (Number.isInteger(joinedCount)) { | ||
|
|
@@ -1699,12 +1700,47 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> { | |
| }); | ||
| } | ||
|
|
||
| // Convert back to the legacy heroes format for the `RoomEvent.Summary` event. | ||
| summary["m.heroes"] = heroes?.map((h) => h.userId); | ||
|
|
||
| this.emit(RoomEvent.Summary, summary as IRoomSummary); | ||
dbkr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * Takes information from the MSC4186 room summary and updates the room with it. | ||
| * | ||
| * @param heroes | ||
| * @param joinedCount | ||
| * @param invitedCount | ||
dbkr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| public setMSC4186SummaryData( | ||
| heroes: MSC4186Hero[] | undefined, | ||
| joinedCount: number | undefined, | ||
| invitedCount: number | undefined, | ||
| ): void { | ||
| if (heroes) { | ||
| this.heroes = heroes | ||
| .filter((h) => h.user_id !== this.myUserId) | ||
| .map((h) => ({ | ||
| userId: h.user_id, | ||
| displayName: h.displayname, | ||
| avatarUrl: h.avatar_url, | ||
| fromMSC4186: true, | ||
| })); | ||
| } | ||
| if (joinedCount !== undefined && Number.isInteger(joinedCount)) { | ||
dbkr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.currentState.setJoinedMemberCount(joinedCount); | ||
| } | ||
| if (invitedCount !== undefined && Number.isInteger(invitedCount)) { | ||
|
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. ditto
Member
Author
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. Typescript complains without these checks as Number.isInteger doesn't accept |
||
| this.currentState.setInvitedMemberCount(invitedCount); | ||
| } | ||
|
|
||
| // Construct a summary object to emit as the event wants the info in a single object | ||
| // more like old-style (/v3/sync) summaries. | ||
| this.emit(RoomEvent.Summary, { | ||
| "m.heroes": this.heroes ? this.heroes.map((h) => h.userId) : [], | ||
| "m.joined_member_count": joinedCount, | ||
| "m.invited_member_count": invitedCount, | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Whether to send encrypted messages to devices within this room. | ||
| * @param value - true to blacklist unverified devices, null | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.