From 7bf29d411f5bfa1acd9589bef29b239aa9746d29 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 13 Mar 2024 13:07:30 -0700 Subject: [PATCH] atproto: only enable indieweb.org and snarfed.org, for now --- activitypub.py | 2 +- atproto.py | 14 ++++++++++++-- models.py | 3 +++ protocol.py | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/activitypub.py b/activitypub.py index 256821a..6fa87c8 100644 --- a/activitypub.py +++ b/activitypub.py @@ -401,7 +401,7 @@ class ActivityPub(User, Protocol): sig = headers.get('Signature') if not sig: if appengine_info.DEBUG: - logging.info('No HTTP Signature, allowing due to DEBUG=true') + logger.info('No HTTP Signature, allowing due to DEBUG=true') return error('No HTTP Signature', status=401) diff --git a/atproto.py b/atproto.py index 06b7a2a..75a3049 100644 --- a/atproto.py +++ b/atproto.py @@ -485,7 +485,12 @@ def poll_notifications(): headers={'User-Agent': USER_AGENT}) for user in users: - logging.debug(f'Fetching notifs for {user.key.id()}') + # TODO: remove for launch + if not DEBUG and user.key.id() not in ['indieweb.org', 'snarfed.org']: + logger.info(f'Skipping {user.key.id()}') + continue + + logger.debug(f'Fetching notifs for {user.key.id()}') # TODO: store and use cursor # seenAt would be easier, but they don't support it yet @@ -536,7 +541,12 @@ def poll_posts(): headers={'User-Agent': USER_AGENT}) for user in users: - logging.debug(f'Fetching posts for {user.key.id()}') + # TODO: remove for launch + if not DEBUG and user.key.id() not in ['indieweb.org', 'snarfed.org']: + logger.info(f'Skipping {user.key.id()}') + continue + + logger.debug(f'Fetching posts for {user.key.id()}') # TODO: store and use cursor # seenAt would be easier, but they don't support it yet diff --git a/models.py b/models.py index 98e1e2b..f4acf95 100644 --- a/models.py +++ b/models.py @@ -868,6 +868,9 @@ class Object(StringIdModel): # TODO: optimize! this is called serially in loops, eg in home.html if set(actor.keys()) == {'id'} and self.source_protocol: proto = PROTOCOLS[self.source_protocol] + # STATE: this load gets the DID doc, not the profile object + # should we start using at://[did] as actor/author? or special case + # atproto here? actor_obj = proto.load(actor['id'], remote=False) if actor_obj and actor_obj.as1: actor = actor_obj.as1 diff --git a/protocol.py b/protocol.py index 6d13222..2a64a29 100644 --- a/protocol.py +++ b/protocol.py @@ -1245,7 +1245,7 @@ def send_task(): target = Target(uri=url, protocol=protocol) obj = ndb.Key(urlsafe=form['obj']).get() - logging.info(f'Sending {obj.key.id()} AS1: {json_dumps(obj.as1, indent=2)}') + logger.info(f'Sending {obj.key.id()} AS1: {json_dumps(obj.as1, indent=2)}') if (target not in obj.undelivered and target not in obj.failed and 'force' not in request.values):