From 68d1442a8f551571f64ba29da9103c3741708985 Mon Sep 17 00:00:00 2001 From: Ryan Ciehanski Date: Wed, 15 Apr 2020 14:10:07 -0500 Subject: [PATCH 1/3] Update copySuccess & appendSuccess messages according to RFCs. https://github.com/ProtonMail/proton-bridge/issues/3 --- internal/imap/uidplus/extension.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/imap/uidplus/extension.go b/internal/imap/uidplus/extension.go index ff86a70d..5eee2123 100644 --- a/internal/imap/uidplus/extension.go +++ b/internal/imap/uidplus/extension.go @@ -38,8 +38,8 @@ const Capability = "UIDPLUS" const ( copyuid = "COPYUID" appenduid = "APPENDUID" - copySuccess = "COPY successful" - appendSucess = "APPEND successful" + copySuccess = "COPY completed" + appendSucess = "APPEND completed" ) var log = logrus.WithField("pkg", "imap/uidplus") //nolint[gochecknoglobals] From 76b480298abf2cbae7eae4062cf3713d90515dbf Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Tue, 21 Apr 2020 13:13:02 +0200 Subject: [PATCH 2/3] fix: better error messages for 422 --- internal/store/event_loop.go | 2 +- pkg/pmapi/client.go | 10 ++++++++-- pkg/pmapi/res.go | 8 ++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/internal/store/event_loop.go b/internal/store/event_loop.go index 0238c983..b010f059 100644 --- a/internal/store/event_loop.go +++ b/internal/store/event_loop.go @@ -431,7 +431,7 @@ func (loop *eventLoop) processMessages(eventLog *logrus.Entry, messages []*pmapi msgLog.WithError(err).Warning("Message was not present in DB. Trying fetch...") if msg, err = loop.apiClient.GetMessage(message.ID); err != nil { - if err == pmapi.ErrNoSuchAPIID { + if _, ok := err.(*pmapi.ErrUnprocessableEntity); ok { msgLog.WithError(err).Warn("Skipping message update because message exists neither in local DB nor on API") err = nil continue diff --git a/pkg/pmapi/client.go b/pkg/pmapi/client.go index 22032b8f..fba354e4 100644 --- a/pkg/pmapi/client.go +++ b/pkg/pmapi/client.go @@ -56,10 +56,16 @@ var ( ErrInvalidToken = errors.New("refresh token invalid") ErrAPINotReachable = errors.New("cannot reach the server") ErrUpgradeApplication = errors.New("application upgrade required") - - ErrNoSuchAPIID = errors.New("no such API ID") ) +type ErrUnprocessableEntity struct { + error +} + +func (err *ErrUnprocessableEntity) Error() string { + return err.error.Error() +} + type ErrUnauthorized struct { error } diff --git a/pkg/pmapi/res.go b/pkg/pmapi/res.go index 07a5cada..dc388e4a 100644 --- a/pkg/pmapi/res.go +++ b/pkg/pmapi/res.go @@ -17,7 +17,11 @@ package pmapi -import "net/http" +import ( + "net/http" + + "github.com/pkg/errors" +) // Common response codes. const ( @@ -38,7 +42,7 @@ type Res struct { // Err returns error if the response is an error. Otherwise, returns nil. func (res Res) Err() error { if res.StatusCode == http.StatusUnprocessableEntity { - return ErrNoSuchAPIID + return &ErrUnprocessableEntity{errors.New(res.Error)} } if res.ResError == nil { From a1b01d5922a06743199f4655ca6b45b2aec9a441 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 24 Apr 2020 08:47:48 +0000 Subject: [PATCH 3/3] feat: add nogui build in makefile --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e17da8a..fcb83ee7 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ export GO111MODULE=on GOOS:=$(shell go env GOOS) ## Build -.PHONY: build check-has-go +.PHONY: build build-nogui check-has-go VERSION?=1.2.7-git REVISION:=$(shell git rev-parse --short=10 HEAD) @@ -36,6 +36,9 @@ TGZ_TARGET:=bridge_${GOOS}_${REVISION}.tgz build: ${TGZ_TARGET} +build-nogui: + go build ${BUILD_FLAGS_NOGUI} -o Desktop-Bridge cmd/Desktop-Bridge/main.go + ${TGZ_TARGET}: ${DEPLOY_DIR}/${GOOS} rm -f $@ cd ${DEPLOY_DIR} && tar czf ../../../$@ ${GOOS}