kopia lustrzana https://github.com/snarfed/bridgy-fed
add handle_or_id kwarg to common.is_enabled
for allowlist of test users while testing a given pair of protocolspull/951/head
rodzic
5767ffabb5
commit
056644d19e
|
@ -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 = '<img src="/static/atproto_logo.png">'
|
||||
PDS_URL = f'https://{ABBREV}{common.SUPERDOMAIN}/'
|
||||
|
|
15
common.py
15
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
|
||||
|
||||
|
||||
|
|
|
@ -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'))
|
||||
|
|
Ładowanie…
Reference in New Issue