mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 00:52:40 +00:00
appservice: keep the crypto method set on the wrapped state store
The lazy store embedded appservice.StateStore, but the client's store is also type-asserted to crypto.StateStore -- a wider interface -- and NewCryptoHelper refuses to start when that assertion fails. Embedding the narrower interface dropped GetEncryptionEvent and FindSharedRooms from the concrete type, so the bot died on startup with "the client state store must implement crypto.StateStore". Embed both, assert both at compile time, and resolve GetEncryptionEvent lazily like IsEncrypted since the crypto machine reads megolm rotation settings through it.
This commit is contained in:
@@ -110,7 +110,11 @@ func newAppserviceSession(cfg Config) (*Session, error) {
|
||||
// use, since there is no /sync to backfill it. Must be installed before the
|
||||
// first BotClient() call: makeClient copies as.StateStore into the client, and
|
||||
// caches the client.
|
||||
store := newLazyStateStore(as.StateStore)
|
||||
inner, ok := as.StateStore.(innerStateStore)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("appservice state store %T does not implement crypto.StateStore", as.StateStore)
|
||||
}
|
||||
store := newLazyStateStore(inner)
|
||||
as.StateStore = store
|
||||
|
||||
client := as.BotClient() // as_token auth + SetAppServiceUserID (?user_id=) assertion
|
||||
|
||||
Reference in New Issue
Block a user