kopia lustrzana https://github.com/snarfed/bridgy-fed
Protocol.for_id: return Web for protocol bot users
rodzic
d4a56127d9
commit
304994e3b7
|
@ -4,7 +4,7 @@ from datetime import timedelta
|
|||
import logging
|
||||
import re
|
||||
from threading import Lock
|
||||
from urllib.parse import urljoin
|
||||
from urllib.parse import urljoin, urlparse
|
||||
|
||||
from cachetools import cached, LRUCache
|
||||
from flask import g, request
|
||||
|
@ -301,10 +301,11 @@ class Protocol:
|
|||
if not id:
|
||||
return None
|
||||
|
||||
# step 1: check for our per-protocol subdomains
|
||||
if util.is_web(id):
|
||||
# step 1: check for our per-protocol subdomains
|
||||
is_homepage = urlparse(id).path.strip('/') == ''
|
||||
by_subdomain = Protocol.for_bridgy_subdomain(id)
|
||||
if by_subdomain:
|
||||
if by_subdomain and not is_homepage:
|
||||
logger.info(f' {by_subdomain.LABEL} owns id {id}')
|
||||
return by_subdomain
|
||||
|
||||
|
|
|
@ -90,8 +90,13 @@ class ProtocolTest(TestCase):
|
|||
('foo://bar', None),
|
||||
('fake:foo', Fake),
|
||||
('at://foo', ATProto),
|
||||
# TODO: remove? should we require normalized ids?
|
||||
('https://ap.brid.gy/foo/bar', ActivityPub),
|
||||
('https://web.brid.gy/foo/bar', Web),
|
||||
('https://fed.brid.gy/', Web),
|
||||
('https://web.brid.gy/', Web),
|
||||
('https://bsky.brid.gy/', Web),
|
||||
('bsky.brid.gy', Web),
|
||||
]:
|
||||
self.assertEqual(expected, Protocol.for_id(id, remote=False))
|
||||
self.assertEqual(expected, Protocol.for_id(id, remote=True))
|
||||
|
|
Ładowanie…
Reference in New Issue