From 4efb0d3e350c5a3d2f7188ceba757c9622d26dac Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Tue, 23 Apr 2024 16:58:30 -0700 Subject: [PATCH] ATProto: tweak polling: every 5 min, 10 items each call --- atproto.py | 4 ++-- cron.yaml | 4 ++-- tests/test_atproto.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/atproto.py b/atproto.py index 8d1c4e1..a8bb71a 100644 --- a/atproto.py +++ b/atproto.py @@ -594,7 +594,7 @@ def poll_notifications(): client.session['accessJwt'] = service_jwt(os.environ['APPVIEW_HOST'], repo_did=did, privkey=repo.signing_key) - resp = client.app.bsky.notification.listNotifications() + resp = client.app.bsky.notification.listNotifications(limit=10) for notif in resp['notifications']: actor_did = notif['author']['did'] logger.debug(f'Got {notif["reason"]} from {notif["author"]["handle"]} {notif["uri"]} {notif["cid"]} : {json_dumps(notif, indent=2)}') @@ -653,7 +653,7 @@ def poll_posts(): client.session['accessJwt'] = service_jwt(os.environ['APPVIEW_HOST'], repo_did=did, privkey=repo.signing_key) - resp = client.app.bsky.feed.getTimeline() + resp = client.app.bsky.feed.getTimeline(limit=10) for item in resp['feed']: # TODO: handle reposts once we have a URI for them # https://github.com/bluesky-social/atproto/issues/1811 diff --git a/cron.yaml b/cron.yaml index b7b81f2..d9b0738 100644 --- a/cron.yaml +++ b/cron.yaml @@ -4,10 +4,10 @@ cron: - description: ATProto poll posts url: /queue/atproto-poll-posts - schedule: every 15 minutes + schedule: every 5 minutes target: hub - description: ATProto poll notifications url: /queue/atproto-poll-notifs - schedule: every 15 minutes + schedule: every 5 minutes target: hub diff --git a/tests/test_atproto.py b/tests/test_atproto.py index 3144375..31ffecd 100644 --- a/tests/test_atproto.py +++ b/tests/test_atproto.py @@ -1192,7 +1192,7 @@ class ATProtoTest(TestCase): self.assertEqual(200, resp.status_code) expected_list_notifs = call( - 'https://api.bsky-sandbox.dev/xrpc/app.bsky.notification.listNotifications', + 'https://api.bsky-sandbox.dev/xrpc/app.bsky.notification.listNotifications?limit=10', json=None, data=None, headers={ 'Content-Type': 'application/json', @@ -1290,7 +1290,7 @@ class ATProtoTest(TestCase): self.assertEqual(200, resp.status_code) get_timeline = call( - 'https://api.bsky-sandbox.dev/xrpc/app.bsky.feed.getTimeline', + 'https://api.bsky-sandbox.dev/xrpc/app.bsky.feed.getTimeline?limit=10', json=None, data=None, headers={ 'Content-Type': 'application/json',