Skip to content

Various fixes to sync, event decoding, login, and registration

Charles Wright requested to merge cvwright/sync_decoding_fixes into main

A handful of assorted changes that I needed in order to start running basic tests against a local homeserver on my development machine.

  • Updates to LoginSession and SignupSession to enable oldschool Matrix username and password auth

  • Made UserId conform to CodingKey and added an extension for KeyedDecodingContainer to enable automatic decoding of dictionaries with UserIds as keys. This was necessary to support m.room.power_levels events.

  • Also made RoomId conform to CodingKey in a similar way, and added dictionary decoding support for it too. Then commented out the type-specific decoding functions for RoomId dictionaries in SyncRequestBody.swift. Keeping the old code around for now in case we run into problems with the new stuff.

  • It turns out that almost none of the elements of a m.room.power_levels event are required, so made them all optionals.

  • In sync(), save our sync token before returning, so we know that we don't lose it. Also, we now do this on the MainActor thread to ensure that ObservableObject picks up on the change for SwiftUI.

  • Only for the tests, an extension to Session with a new function syncUntil(f: () -> Bool). This idea was shamelessly borrowed from the Matrix Complement test suite. It simply calls sync() in a loop until the function returns true (or until it hits some limit on the number of tries).

  • Edit: Also added support for homeservers that include a port in their URL. This impacts UserId and RoomId too.

Edited by Charles Wright

Merge request reports

Loading