mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 12:46:46 +00:00
feat: add ErrNoSuchMessage to pmapi
This commit is contained in:
committed by
Jakub Cuth
parent
d1e63254f2
commit
e1ecc11f38
@ -15,6 +15,7 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
|||||||
* GODT-282 Completely delete old draft instead moving to trash when user updates draft
|
* GODT-282 Completely delete old draft instead moving to trash when user updates draft
|
||||||
* Adding DSN Sentry as build time parameter
|
* Adding DSN Sentry as build time parameter
|
||||||
* GODT-124 bump go-appdir from v1.0.0 to v1.1.0
|
* GODT-124 bump go-appdir from v1.0.0 to v1.1.0
|
||||||
|
* Skip processing message update event if http statuscode is 422
|
||||||
|
|
||||||
## [v1.2.6] Donghai - beta (2020-03-XXX)
|
## [v1.2.6] Donghai - beta (2020-03-XXX)
|
||||||
|
|
||||||
|
|||||||
@ -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...")
|
msgLog.WithError(err).Warning("Message was not present in DB. Trying fetch...")
|
||||||
|
|
||||||
if msg, err = loop.store.fetchMessage(message.ID); err != nil {
|
if msg, err = loop.store.fetchMessage(message.ID); err != nil {
|
||||||
if err != pmapi.ErrAPINotReachable {
|
if err == pmapi.ErrNoSuchMessage {
|
||||||
msgLog.WithError(err).Warn("Skipping message update because message exists neither in local DB nor on API")
|
msgLog.WithError(err).Warn("Skipping message update because message exists neither in local DB nor on API")
|
||||||
err = nil
|
err = nil
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -56,6 +56,8 @@ var (
|
|||||||
ErrInvalidToken = errors.New("refresh token invalid")
|
ErrInvalidToken = errors.New("refresh token invalid")
|
||||||
ErrAPINotReachable = errors.New("cannot reach the server")
|
ErrAPINotReachable = errors.New("cannot reach the server")
|
||||||
ErrUpgradeApplication = errors.New("application upgrade required")
|
ErrUpgradeApplication = errors.New("application upgrade required")
|
||||||
|
|
||||||
|
ErrNoSuchMessage = errors.New("no such message")
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrUnauthorized struct {
|
type ErrUnauthorized struct {
|
||||||
|
|||||||
@ -532,7 +532,13 @@ func (c *Client) GetMessage(id string) (msg *Message, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if res.StatusCode == http.StatusUnprocessableEntity {
|
||||||
|
err = ErrNoSuchMessage
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
msg, err = res.Message, res.Err()
|
msg, err = res.Message, res.Err()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package pmapi
|
package pmapi
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
// Common response codes.
|
// Common response codes.
|
||||||
const (
|
const (
|
||||||
CodeOk = 1000
|
CodeOk = 1000
|
||||||
|
|||||||
Reference in New Issue
Block a user