Skip to content

Commit 2cce29e

Browse files
author
James Houlahan
committed
GODT-1201: bump gopenpgp to 2.1.10 and update crypto time
1 parent ef12233 commit 2cce29e

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/ProtonMail/go-rfc5322 v0.8.0
2020
github.com/ProtonMail/go-srp v0.0.0-20210514134713-bd9454f3fa01
2121
github.com/ProtonMail/go-vcard v0.0.0-20180326232728-33aaa0a0c8a5
22-
github.com/ProtonMail/gopenpgp/v2 v2.1.9
22+
github.com/ProtonMail/gopenpgp/v2 v2.1.10
2323
github.com/PuerkitoBio/goquery v1.5.1
2424
github.com/abiosoft/ishell v2.0.0+incompatible
2525
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ github.com/ProtonMail/go-srp v0.0.0-20210514134713-bd9454f3fa01 h1:sRxNvPGnJFh6y
3030
github.com/ProtonMail/go-srp v0.0.0-20210514134713-bd9454f3fa01/go.mod h1:jOXzdvWTILIJzl83yzi/EZcnnhpI+A/5EyflaeVfi/0=
3131
github.com/ProtonMail/go-vcard v0.0.0-20180326232728-33aaa0a0c8a5 h1:Uga1DHFN4GUxuDQr0F71tpi8I9HqPIlZodZAI1lR6VQ=
3232
github.com/ProtonMail/go-vcard v0.0.0-20180326232728-33aaa0a0c8a5/go.mod h1:oeP9CMN+ajWp5jKp1kue5daJNwMMxLF+ujPaUIoJWlA=
33-
github.com/ProtonMail/gopenpgp/v2 v2.1.9 h1:MdvkFBP8ldOHYOoaVct9LO+Zv5rl6VdeN1QurntRmkc=
34-
github.com/ProtonMail/gopenpgp/v2 v2.1.9/go.mod h1:CHIXesUdnPxIxtJTg2P/cxoA0cvUwIBpZIS8SsY82QA=
33+
github.com/ProtonMail/gopenpgp/v2 v2.1.10 h1:WPwpzVQFvzzFIzHCsJ1RzuVkN4JsMIydl/0vc05yU0E=
34+
github.com/ProtonMail/gopenpgp/v2 v2.1.10/go.mod h1:CHIXesUdnPxIxtJTg2P/cxoA0cvUwIBpZIS8SsY82QA=
3535
github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE=
3636
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
3737
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=

pkg/pmapi/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func newManager(cfg Config) *manager {
5959
// wrapped in JSON. If error is returned, `handleRequestFailure` is called,
6060
// otherwise `handleRequestSuccess` is called.
6161
m.rc.SetError(&Error{})
62+
m.rc.OnAfterResponse(updateTime)
6263
m.rc.OnAfterResponse(m.catchAPIError)
6364
m.rc.OnAfterResponse(m.handleRequestSuccess)
6465
m.rc.OnError(m.handleRequestFailure)

pkg/pmapi/response.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strconv"
2424
"time"
2525

26+
"github.com/ProtonMail/gopenpgp/v2/crypto"
2627
"github.com/go-resty/resty/v2"
2728
"github.com/pkg/errors"
2829
"github.com/sirupsen/logrus"
@@ -71,6 +72,16 @@ func (m *manager) catchAPIError(_ *resty.Client, res *resty.Response) error {
7172
return err
7273
}
7374

75+
func updateTime(_ *resty.Client, res *resty.Response) error {
76+
if date, err := time.Parse(time.RFC1123, res.Header().Get("Date")); err != nil {
77+
log.WithError(err).Warning("Cannot parse header date")
78+
} else {
79+
crypto.UpdateTime(date.Unix())
80+
}
81+
82+
return nil
83+
}
84+
7485
func catchRetryAfter(_ *resty.Client, res *resty.Response) (time.Duration, error) {
7586
if res.StatusCode() == http.StatusTooManyRequests {
7687
if after := res.Header().Get("Retry-After"); after != "" {

0 commit comments

Comments
 (0)