Include m.room.encryption state events in timeline in sync filter

This commit is contained in:
Tulir Asokan 2020-11-29 02:05:11 +02:00
parent f3854524bc
commit 45f71dbaa3
2 changed files with 25 additions and 23 deletions

View File

@ -36,6 +36,7 @@ import (
type AuthCache struct {
NextBatch string `yaml:"next_batch"`
FilterID string `yaml:"filter_id"`
FilterVersion int `yaml:"filter_version"`
InitialSyncDone bool `yaml:"initial_sync_done"`
}
@ -262,12 +263,18 @@ func (config *Config) GetUserID() id.UserID {
return config.UserID
}
const FilterVersion = 1
func (config *Config) SaveFilterID(_ id.UserID, filterID string) {
config.AuthCache.FilterID = filterID
config.AuthCache.FilterVersion = FilterVersion
config.SaveAuthCache()
}
func (config *Config) LoadFilterID(_ id.UserID) string {
if config.AuthCache.FilterVersion != FilterVersion {
return ""
}
return config.AuthCache.FilterID
}

View File

@ -226,37 +226,32 @@ func (s *GomuksSyncer) OnFailedSync(res *mautrix.RespSync, err error) (time.Dura
// GetFilterJSON returns a filter with a timeline limit of 50.
func (s *GomuksSyncer) GetFilterJSON(_ id.UserID) *mautrix.Filter {
stateEvents := []event.Type{
event.StateMember,
event.StateRoomName,
event.StateTopic,
event.StateCanonicalAlias,
event.StatePowerLevels,
event.StateTombstone,
event.StateEncryption,
}
messageEvents := []event.Type{
event.EventMessage,
event.EventRedaction,
event.EventEncrypted,
event.EventSticker,
event.EventReaction,
}
return &mautrix.Filter{
Room: mautrix.RoomFilter{
IncludeLeave: false,
State: mautrix.FilterPart{
LazyLoadMembers: true,
Types: []event.Type{
event.StateMember,
event.StateRoomName,
event.StateTopic,
event.StateCanonicalAlias,
event.StatePowerLevels,
event.StateTombstone,
event.StateEncryption,
},
Types: stateEvents,
},
Timeline: mautrix.FilterPart{
LazyLoadMembers: true,
Types: []event.Type{
event.EventMessage,
event.EventRedaction,
event.EventEncrypted,
event.EventSticker,
event.EventReaction,
event.StateMember,
event.StateRoomName,
event.StateTopic,
event.StateCanonicalAlias,
event.StatePowerLevels,
event.StateTombstone,
},
Types: append(messageEvents, stateEvents...),
Limit: 50,
},
Ephemeral: mautrix.FilterPart{