From 341a6501e66927cb58d1138a20252d63ae76952a Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 17 Apr 2020 09:09:34 +0200 Subject: [PATCH] fix: don't return error when event data is nil --- internal/bridge/mocks/mocks.go | 9 +++++---- internal/frontend/autoconfig/applemail.go | 2 +- internal/frontend/qt/frontend.go | 2 +- internal/store/event_loop.go | 8 ++++---- internal/store/mocks/mocks.go | 3 ++- internal/store/mocks/utils_mocks.go | 3 ++- pkg/pmapi/res.go | 2 -- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/internal/bridge/mocks/mocks.go b/internal/bridge/mocks/mocks.go index 16d42a7f..62e7998e 100644 --- a/internal/bridge/mocks/mocks.go +++ b/internal/bridge/mocks/mocks.go @@ -5,12 +5,13 @@ package mocks import ( - credentials "github.com/ProtonMail/proton-bridge/internal/bridge/credentials" - pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi" - crypto "github.com/ProtonMail/gopenpgp/crypto" - gomock "github.com/golang/mock/gomock" io "io" reflect "reflect" + + crypto "github.com/ProtonMail/gopenpgp/crypto" + credentials "github.com/ProtonMail/proton-bridge/internal/bridge/credentials" + pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi" + gomock "github.com/golang/mock/gomock" ) // MockConfiger is a mock of Configer interface diff --git a/internal/frontend/autoconfig/applemail.go b/internal/frontend/autoconfig/applemail.go index cbc05fc4..faa8146a 100644 --- a/internal/frontend/autoconfig/applemail.go +++ b/internal/frontend/autoconfig/applemail.go @@ -28,9 +28,9 @@ import ( "strings" "time" + mobileconfig "github.com/ProtonMail/go-apple-mobileconfig" "github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/internal/frontend/types" - mobileconfig "github.com/ProtonMail/go-apple-mobileconfig" ) func init() { //nolint[gochecknoinit] diff --git a/internal/frontend/qt/frontend.go b/internal/frontend/qt/frontend.go index 00010fca..00b76c3c 100644 --- a/internal/frontend/qt/frontend.go +++ b/internal/frontend/qt/frontend.go @@ -36,6 +36,7 @@ import ( "sync" "time" + "github.com/ProtonMail/go-autostart" "github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/internal/frontend/autoconfig" @@ -44,7 +45,6 @@ import ( "github.com/ProtonMail/proton-bridge/pkg/config" "github.com/ProtonMail/proton-bridge/pkg/ports" "github.com/ProtonMail/proton-bridge/pkg/useragent" - "github.com/ProtonMail/go-autostart" //"github.com/ProtonMail/proton-bridge/pkg/keychain" "github.com/ProtonMail/proton-bridge/pkg/listener" diff --git a/internal/store/event_loop.go b/internal/store/event_loop.go index 62b93339..0a2f5a41 100644 --- a/internal/store/event_loop.go +++ b/internal/store/event_loop.go @@ -405,8 +405,8 @@ func (loop *eventLoop) processMessages(eventLog *logrus.Entry, messages []*pmapi msgLog.Debug("Processing EventCreate for message") if message.Created == nil { - msgLog.Error("Got EventCreate with nil message") - return errors.Wrap(err, "no message to put into DB") + msgLog.Warn("Got EventCreate with nil message") + continue } if err = loop.store.createOrUpdateMessageEvent(message.Created); err != nil { @@ -417,8 +417,8 @@ func (loop *eventLoop) processMessages(eventLog *logrus.Entry, messages []*pmapi msgLog.Debug("Processing EventUpdate(Flags) for message") if message.Updated == nil { - msgLog.Errorf("Got EventUpdate(Flags) with nil message") - return errors.Wrap(err, "missing update information") + msgLog.Warn("Got EventUpdate(Flags) with nil message") + continue } var msg *pmapi.Message diff --git a/internal/store/mocks/mocks.go b/internal/store/mocks/mocks.go index 0ee60bf1..486cfaef 100644 --- a/internal/store/mocks/mocks.go +++ b/internal/store/mocks/mocks.go @@ -5,8 +5,9 @@ package mocks import ( - gomock "github.com/golang/mock/gomock" reflect "reflect" + + gomock "github.com/golang/mock/gomock" ) // MockPanicHandler is a mock of PanicHandler interface diff --git a/internal/store/mocks/utils_mocks.go b/internal/store/mocks/utils_mocks.go index 3f43bb43..940bf172 100644 --- a/internal/store/mocks/utils_mocks.go +++ b/internal/store/mocks/utils_mocks.go @@ -5,9 +5,10 @@ package mocks import ( - gomock "github.com/golang/mock/gomock" reflect "reflect" time "time" + + gomock "github.com/golang/mock/gomock" ) // MockListener is a mock of Listener interface diff --git a/pkg/pmapi/res.go b/pkg/pmapi/res.go index c6b5e44a..5f196a34 100644 --- a/pkg/pmapi/res.go +++ b/pkg/pmapi/res.go @@ -17,8 +17,6 @@ package pmapi -import "net/http" - // Common response codes. const ( CodeOk = 1000