Stale, not State

This commit is contained in:
Till Faelligen 2023-10-02 17:03:07 +02:00
parent 688129fbcb
commit 0a116fb51a
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -183,7 +183,7 @@ func (u *DeviceListUpdater) Start() error {
// Filter out dupe domains, as processServer is going to get all users anyway // Filter out dupe domains, as processServer is going to get all users anyway
seenDomains := make(map[spec.ServerName]struct{}) seenDomains := make(map[spec.ServerName]struct{})
newStateLists := make([]string, 0, len(staleLists)) newStaleLists := make([]string, 0, len(staleLists))
for _, userID := range staleLists { for _, userID := range staleLists {
_, domain, err := gomatrixserverlib.SplitID('@', userID) _, domain, err := gomatrixserverlib.SplitID('@', userID)
if err != nil { if err != nil {
@ -193,14 +193,14 @@ func (u *DeviceListUpdater) Start() error {
if _, ok := seenDomains[domain]; ok { if _, ok := seenDomains[domain]; ok {
continue continue
} }
newStateLists = append(newStateLists, userID) newStaleLists = append(newStaleLists, userID)
seenDomains[domain] = struct{}{} seenDomains[domain] = struct{}{}
} }
offset, step := time.Second*10, time.Second offset, step := time.Second*10, time.Second
if max := len(newStateLists); max > 120 { if max := len(newStaleLists); max > 120 {
step = (time.Second * 120) / time.Duration(max) step = (time.Second * 120) / time.Duration(max)
} }
for _, userID := range newStateLists { for _, userID := range newStaleLists {
userID := userID // otherwise we are only sending the last entry userID := userID // otherwise we are only sending the last entry
time.AfterFunc(offset, func() { time.AfterFunc(offset, func() {
u.notifyWorkers(userID) u.notifyWorkers(userID)