Adding support for MSC3202 for E2E appservice support
Looking at https://github.com/matrix-org/matrix-spec-proposals/pull/3202 seems like a pretty straight forward implementation. I think I can contribute that part, but would love for direction on which files it should be implemented on.
Ignoring MSC2409, we need device_lists, device_one_time_keys_count and device_unused_fallback_key_types (the latter isn't implemented yet, iirc)
device_lists and device_one_time_keys_count currently have some internal functions in the SyncAPI:
https://github.com/matrix-org/dendrite/blob/d65449c7822e89b506bf2caa7a098e38970f6f27/syncapi/internal/keychange.go#L36 https://github.com/matrix-org/dendrite/blob/d65449c7822e89b506bf2caa7a098e38970f6f27/syncapi/internal/keychange.go#L52-L55
Those are used for /sync responses and most likely will need to be "public" so the appservice API can use them.
So IMO, we need to modify https://github.com/matrix-org/dendrite/blob/main/appservice/consumers/roomserver.go to:
- Add OTKs for all users the appservice is interested in when the consumer receives a
m.room.encryptedevent - Have
appserviceStatekeep track of theStreamPosition(from, in this case) to be able to calculatedevice_lists - Make the mentioned internal functions public