Handle key missing errors when syncing app state

This commit is contained in:
Tulir Asokan 2022-05-16 11:43:09 +03:00
parent 66a00570b4
commit 3cafd59cf7
3 changed files with 7 additions and 4 deletions

View file

@ -1135,7 +1135,10 @@ func (handler *CommandHandler) CommandSync(ce *CommandEvent) {
if appState {
for _, name := range appstate.AllPatchNames {
err := ce.User.Client.FetchAppState(name, true, false)
if err != nil {
if errors.Is(err, appstate.ErrKeyNotFound) {
ce.Reply("Key not found error syncing app state %s: %v\n\nKey requests are sent automatically, and the sync should happen in the background after your phone responds.", name, err)
return
} else if err != nil {
ce.Reply("Error syncing app state %s: %v", name, err)
} else if name == appstate.WAPatchCriticalUnblockLow {
ce.Reply("Synced app state %s, contact sync running in background", name)

2
go.mod
View file

@ -10,7 +10,7 @@ require (
github.com/prometheus/client_golang v1.12.2-0.20220514081015-5d584e2717ef
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.1
go.mau.fi/whatsmeow v0.0.0-20220516080154-a168fde5a9de
go.mau.fi/whatsmeow v0.0.0-20220516084153-89886dde861b
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
golang.org/x/net v0.0.0-20220513224357-95641704303c
google.golang.org/protobuf v1.28.0

4
go.sum
View file

@ -62,8 +62,8 @@ github.com/yuin/goldmark v1.4.12 h1:6hffw6vALvEDqJ19dOJvJKOoAOKe4NDaTqvd2sktGN0=
github.com/yuin/goldmark v1.4.12/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0 h1:3IQF2bgAyibdo77hTejwuJe4jlypj9QaE4xCQuxrThM=
go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0/go.mod h1:kBOXTvYyDG/q1Ihgvd4J6WenGPh7wtEGvPKF6vmf5ak=
go.mau.fi/whatsmeow v0.0.0-20220516080154-a168fde5a9de h1:656AnW7jfFOU42e3py0beh5rj5/Ikg7sxmyQBLiSJGA=
go.mau.fi/whatsmeow v0.0.0-20220516080154-a168fde5a9de/go.mod h1:iUBgOLNaqShLrR17u0kIiRptIGFH+nbT1tRhaWBEX/c=
go.mau.fi/whatsmeow v0.0.0-20220516084153-89886dde861b h1:ivuB8z2Ai8wJ1aibXWh1Fr1ETmvLIt3JlAoaNXSa6vg=
go.mau.fi/whatsmeow v0.0.0-20220516084153-89886dde861b/go.mod h1:iUBgOLNaqShLrR17u0kIiRptIGFH+nbT1tRhaWBEX/c=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9 h1:NUzdAbFtCJSXU20AOXgeqaUwg8Ypg4MPYmL+d+rsB5c=
golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=