Various fixes to sync, event decoding, login, and registration
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
andSignupSession
to enable oldschool Matrix username and password auth -
Made
UserId
conform toCodingKey
and added an extension forKeyedDecodingContainer
to enable automatic decoding of dictionaries withUserId
s as keys. This was necessary to supportm.room.power_levels
events. -
Also made
RoomId
conform toCodingKey
in a similar way, and added dictionary decoding support for it too. Then commented out the type-specific decoding functions forRoomId
dictionaries inSyncRequestBody.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 theMainActor
thread to ensure thatObservableObject
picks up on the change for SwiftUI. -
Only for the tests, an extension to
Session
with a new functionsyncUntil(f: () -> Bool)
. This idea was shamelessly borrowed from the Matrix Complement test suite. It simply callssync()
in a loop until the function returnstrue
(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
andRoomId
too.