add account data
This commit is contained in:
parent
891e83b54c
commit
23afd6d183
24
client.go
24
client.go
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/event"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
@ -40,3 +41,26 @@ func NewMatrixClient(config *MatrixClientConfig, store mautrix.Storer) (*mautrix
|
||||
}
|
||||
return client, err
|
||||
}
|
||||
|
||||
// SetupAccountDataStore sets the client to use a AccountData store and filter appropriately
|
||||
func SetupAccountDataStore(client *mautrix.Client, token string) error {
|
||||
dataFilter := &mautrix.Filter{
|
||||
AccountData: mautrix.FilterPart{
|
||||
Limit: 20,
|
||||
NotTypes: []event.Type{
|
||||
event.NewEventType(token),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
store := mautrix.NewAccountDataStore(token, client)
|
||||
fID, err := client.CreateFilter(dataFilter)
|
||||
if err != nil {
|
||||
//don't want to continue if we can't keep state
|
||||
return err
|
||||
}
|
||||
uid := client.UserID
|
||||
store.SaveFilterID(uid, fID.FilterID)
|
||||
client.Store = store
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user