mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-11-14 05:52:45 +01:00
Add random offset to starting avatar resync loop
This commit is contained in:
parent
9f0901f560
commit
f0e93bd938
1 changed files with 2 additions and 1 deletions
3
user.go
3
user.go
|
@ -25,6 +25,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -238,7 +239,7 @@ const puppetSyncMinInterval = 7 * 24 * time.Hour
|
|||
const puppetSyncLoopInterval = 4 * time.Hour
|
||||
|
||||
func (user *User) puppetResyncLoop() {
|
||||
user.nextPuppetResync = time.Now().Add(puppetSyncLoopInterval)
|
||||
user.nextPuppetResync = time.Now().Add(puppetSyncLoopInterval).Add(-time.Duration(rand.Intn(3600)) * time.Second)
|
||||
for {
|
||||
time.Sleep(user.nextPuppetResync.Sub(time.Now()))
|
||||
user.nextPuppetResync = time.Now().Add(puppetSyncLoopInterval)
|
||||
|
|
Loading…
Reference in a new issue