diff --git a/atproto.py b/atproto.py index eaa046c..523fb77 100644 --- a/atproto.py +++ b/atproto.py @@ -59,6 +59,7 @@ class ATProto(User, Protocol): https://atproto.com/specs/did """ ABBREV = 'atproto' + # TODO: add second bsky label? inject into PROTOCOLS? PHRASE = 'Bluesky' LOGO_HTML = '' PDS_URL = f'https://{ABBREV}{common.SUPERDOMAIN}/' diff --git a/common.py b/common.py index 12cfeee..080d99d 100644 --- a/common.py +++ b/common.py @@ -83,6 +83,15 @@ util.set_user_agent(USER_AGENT) TASKS_LOCATION = 'us-central1' RUN_TASKS_INLINE = False # overridden by unit tests +USER_ALLOWLIST = ( + 'snarfed.org', + 'did:plc:fdme4gb7mu7zrie7peay7tst', + 'snarfed.bsky.social', + 'did:plc:3ljmtyyjqcjee2kpewgsifvb', + 'https://indieweb.social/users/snarfed', + '@snarfed@indieweb.social', +) + def base64_to_long(x): """Converts from URL safe base64 encoding to long integer. @@ -255,12 +264,13 @@ def add(seq, val): seq.append(val) -def is_enabled(proto_a, proto_b): +def is_enabled(proto_a, proto_b, handle_or_id=None): """Returns True if bridging the two input protocols is enabled, False otherwise. Args: proto_a (Protocol subclass) proto_b (Protocol subclass) + handle_or_id (str): optional user handle or id Returns: bool: @@ -273,6 +283,9 @@ def is_enabled(proto_a, proto_b): if DEBUG and ('fake' in labels or 'other' in labels): return True + if handle_or_id in USER_ALLOWLIST: + return True + return labels in ENABLED_BRIDGES diff --git a/tests/test_common.py b/tests/test_common.py index b92e2cb..73423e6 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -109,3 +109,10 @@ class CommonTest(TestCase): self.assertTrue(common.is_enabled(ATProto, Web)) self.assertTrue(common.is_enabled(Fake, OtherFake)) self.assertFalse(common.is_enabled(ATProto, ActivityPub)) + + self.assertFalse(common.is_enabled( + ATProto, ActivityPub, handle_or_id='unknown')) + self.assertTrue(common.is_enabled( + ATProto, ActivityPub, handle_or_id='snarfed.org')) + self.assertTrue(common.is_enabled( + ATProto, ActivityPub, handle_or_id='did:plc:fdme4gb7mu7zrie7peay7tst'))