kopia lustrzana https://github.com/snarfed/bridgy-fed
make ids.translate_handle support protocol bot users
rodzic
0e8b9ece7e
commit
ce23a72549
5
ids.py
5
ids.py
|
@ -166,8 +166,9 @@ def translate_handle(*, handle, from_, to, enhanced):
|
|||
|
||||
case _, 'atproto' | 'nostr':
|
||||
handle = handle.lstrip('@').replace('@', '.')
|
||||
return (handle if enhanced
|
||||
else f'{handle}.{from_.ABBREV}{SUPERDOMAIN}')
|
||||
if enhanced or handle == PRIMARY_DOMAIN or handle in PROTOCOL_DOMAINS:
|
||||
return handle
|
||||
return f'{handle}.{from_.ABBREV}{SUPERDOMAIN}'
|
||||
|
||||
case 'activitypub', 'web':
|
||||
user, instance = handle.lstrip('@').split('@')
|
||||
|
|
|
@ -109,10 +109,6 @@ class IdsTest(TestCase):
|
|||
(Web, 'user.com', Fake, 'fake:handle:user.com'),
|
||||
(Web, 'user.com', Web, 'user.com'),
|
||||
|
||||
# instance actor, protocol bot user
|
||||
(Web, 'fed.brid.gy', ActivityPub, '@fed.brid.gy@fed.brid.gy'),
|
||||
(Web, 'bsky.brid.gy', ActivityPub, '@bsky.brid.gy@bsky.brid.gy'),
|
||||
|
||||
(ActivityPub, '@user@instance', ActivityPub, '@user@instance'),
|
||||
(ActivityPub, '@user@instance', ATProto, 'user.instance.ap.brid.gy'),
|
||||
(ActivityPub, '@user@instance', Fake, 'fake:handle:@user@instance'),
|
||||
|
@ -127,6 +123,11 @@ class IdsTest(TestCase):
|
|||
(Fake, 'fake:handle:user', ATProto, 'fake:handle:user.fa.brid.gy'),
|
||||
(Fake, 'fake:handle:user', Fake, 'fake:handle:user'),
|
||||
(Fake, 'fake:handle:user', Web, 'fake:handle:user'),
|
||||
|
||||
# instance actor, protocol bot users
|
||||
(Web, 'fed.brid.gy', ActivityPub, '@fed.brid.gy@fed.brid.gy'),
|
||||
(Web, 'bsky.brid.gy', ActivityPub, '@bsky.brid.gy@bsky.brid.gy'),
|
||||
(Web, 'ap.brid.gy', ATProto, 'ap.brid.gy'),
|
||||
]:
|
||||
with self.subTest(from_=from_.LABEL, to=to.LABEL):
|
||||
self.assertEqual(expected, translate_handle(
|
||||
|
|
Ładowanie…
Reference in New Issue