kopia lustrzana https://github.com/snarfed/bridgy-fed
use subdomain_wrap in ids.convert
rodzic
023ffd0b7a
commit
5a07e154ef
4
ids.py
4
ids.py
|
@ -4,7 +4,7 @@ https://fed.brid.gy/docs#translate
|
|||
"""
|
||||
import re
|
||||
|
||||
from common import host_url, SUPERDOMAIN
|
||||
from common import subdomain_wrap, SUPERDOMAIN
|
||||
|
||||
|
||||
def convert_id(*, id, from_proto, to_proto):
|
||||
|
@ -32,7 +32,7 @@ def convert_id(*, id, from_proto, to_proto):
|
|||
user = from_proto.get_for_copy(id)
|
||||
return user.key.id() if user else None
|
||||
case (_, 'activitypub'):
|
||||
return host_url(f'{from_proto.ABBREV}/ap/{id}')
|
||||
return subdomain_wrap(from_proto, f'/ap/{id}')
|
||||
case ('activitypub', 'web'):
|
||||
return id
|
||||
# fake protocol is only for unit tests
|
||||
|
|
|
@ -25,11 +25,11 @@ class IdsTest(TestCase):
|
|||
(ATProto, 'did:plc:456', ActivityPub, 'https://inst/user'),
|
||||
(ATProto, 'did:plc:456', ATProto, 'did:plc:456'),
|
||||
(ATProto, 'did:plc:789', Fake, 'fake:user'),
|
||||
(Fake, 'fake:user', ActivityPub, 'http://localhost/fa/ap/fake:user'),
|
||||
(Fake, 'fake:user', ActivityPub, 'https://fa.brid.gy/ap/fake:user'),
|
||||
(Fake, 'fake:user', ATProto, 'did:plc:789'),
|
||||
(Fake, 'fake:user', Fake, 'fake:user'),
|
||||
(Fake, 'fake:user', Web, 'fake:user'),
|
||||
(Web, 'user.com', ActivityPub, 'http://localhost/web/ap/user.com'),
|
||||
(Web, 'user.com', ActivityPub, 'https://web.brid.gy/ap/user.com'),
|
||||
(Web, 'user.com', ATProto, 'did:plc:123'),
|
||||
(Web, 'user.com', Fake, 'fake:user.com'),
|
||||
(Web, 'user.com', Web, 'user.com'),
|
||||
|
|
|
@ -176,7 +176,7 @@ class UserTest(TestCase):
|
|||
user = self.make_user('fake:user', cls=Fake)
|
||||
self.assertEqual('fake:user', user.id_as(Fake))
|
||||
self.assertEqual('fake:user', user.id_as('fake'))
|
||||
self.assertEqual('http://localhost/fa/ap/fake:user', user.id_as('ap'))
|
||||
self.assertEqual('https://fa.brid.gy/ap/fake:user', user.id_as('ap'))
|
||||
|
||||
def test_handle_as(self):
|
||||
user = self.make_user('fake:user', cls=Fake)
|
||||
|
|
Ładowanie…
Reference in New Issue