Include m.room.encryption state events in timeline in sync filter
This commit is contained in:
parent
f3854524bc
commit
45f71dbaa3
@ -36,6 +36,7 @@ import (
|
|||||||
type AuthCache struct {
|
type AuthCache struct {
|
||||||
NextBatch string `yaml:"next_batch"`
|
NextBatch string `yaml:"next_batch"`
|
||||||
FilterID string `yaml:"filter_id"`
|
FilterID string `yaml:"filter_id"`
|
||||||
|
FilterVersion int `yaml:"filter_version"`
|
||||||
InitialSyncDone bool `yaml:"initial_sync_done"`
|
InitialSyncDone bool `yaml:"initial_sync_done"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,12 +263,18 @@ func (config *Config) GetUserID() id.UserID {
|
|||||||
return config.UserID
|
return config.UserID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FilterVersion = 1
|
||||||
|
|
||||||
func (config *Config) SaveFilterID(_ id.UserID, filterID string) {
|
func (config *Config) SaveFilterID(_ id.UserID, filterID string) {
|
||||||
config.AuthCache.FilterID = filterID
|
config.AuthCache.FilterID = filterID
|
||||||
|
config.AuthCache.FilterVersion = FilterVersion
|
||||||
config.SaveAuthCache()
|
config.SaveAuthCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *Config) LoadFilterID(_ id.UserID) string {
|
func (config *Config) LoadFilterID(_ id.UserID) string {
|
||||||
|
if config.AuthCache.FilterVersion != FilterVersion {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return config.AuthCache.FilterID
|
return config.AuthCache.FilterID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
// GetFilterJSON returns a filter with a timeline limit of 50.
|
||||||
func (s *GomuksSyncer) GetFilterJSON(_ id.UserID) *mautrix.Filter {
|
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{
|
return &mautrix.Filter{
|
||||||
Room: mautrix.RoomFilter{
|
Room: mautrix.RoomFilter{
|
||||||
IncludeLeave: false,
|
IncludeLeave: false,
|
||||||
State: mautrix.FilterPart{
|
State: mautrix.FilterPart{
|
||||||
LazyLoadMembers: true,
|
LazyLoadMembers: true,
|
||||||
Types: []event.Type{
|
Types: stateEvents,
|
||||||
event.StateMember,
|
|
||||||
event.StateRoomName,
|
|
||||||
event.StateTopic,
|
|
||||||
event.StateCanonicalAlias,
|
|
||||||
event.StatePowerLevels,
|
|
||||||
event.StateTombstone,
|
|
||||||
event.StateEncryption,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Timeline: mautrix.FilterPart{
|
Timeline: mautrix.FilterPart{
|
||||||
LazyLoadMembers: true,
|
LazyLoadMembers: true,
|
||||||
Types: []event.Type{
|
Types: append(messageEvents, stateEvents...),
|
||||||
event.EventMessage,
|
|
||||||
event.EventRedaction,
|
|
||||||
event.EventEncrypted,
|
|
||||||
event.EventSticker,
|
|
||||||
event.EventReaction,
|
|
||||||
|
|
||||||
event.StateMember,
|
|
||||||
event.StateRoomName,
|
|
||||||
event.StateTopic,
|
|
||||||
event.StateCanonicalAlias,
|
|
||||||
event.StatePowerLevels,
|
|
||||||
event.StateTombstone,
|
|
||||||
},
|
|
||||||
Limit: 50,
|
Limit: 50,
|
||||||
},
|
},
|
||||||
Ephemeral: mautrix.FilterPart{
|
Ephemeral: mautrix.FilterPart{
|
||||||
|
Loading…
Reference in New Issue
Block a user