Use utcfromtimestamp() when compating bluesky token expiry
authorMagnus Hagander <magnus@hagander.net>
Mon, 25 Aug 2025 10:43:59 +0000 (12:43 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 25 Aug 2025 10:43:59 +0000 (12:43 +0200)
This hopefully fixes the strange "token expired" errors we get that seem
to auto recover after 30 minutes.

postgresqleu/util/messaging/bluesky.py

index fb9fd1948ec2453f89f8fbbe2b8166eb24442b5c..8e1ff1cc68607289ed329870f1f64a2d7eeeec65 100644 (file)
@@ -122,7 +122,7 @@ class Bluesky(object):
     def bsjwt(self):
         if 'accessjwt' in self.providerconfig:
             # If the access token expires within 30 minutes, refresh it!
-            if datetime.fromtimestamp(self.providerconfig['accesstokenexpires']) < datetime.utcnow() + timedelta(minutes=30):
+            if datetime.utcfromtimestamp(self.providerconfig['accesstokenexpires']) < datetime.utcnow() + timedelta(minutes=30):
                 r = requests.post(
                     'https://bsky.social/xrpc/com.atproto.server.refreshSession',
                     headers={'Authorization': 'Bearer {}'.format(self.providerconfig['refreshjwt'])},