kopia lustrzana https://github.com/snarfed/bridgy-fed
AP instance actor: move AS2 JSON files, start adding per-protocol bot users
rodzic
18b1a33d22
commit
e1f9021696
|
@ -7,7 +7,7 @@
|
|||
"id": "https://bsky.brid.gy/bsky.brid.gy",
|
||||
"url": "https://bsky.brid.gy/",
|
||||
"preferredUsername": "bsky.brid.gy",
|
||||
"summary": "Bridgy Fed bot user for Bluesky. To bridge your fediverse account to Bluesky, follow this account or reply <em>yes</em> when it promps you with a DM. <a href="https://fed.brid.gy/docs">More info here.</a>",
|
||||
"summary": "<a href='https://fed.brid.gy/'>Bridgy Fed</a> bot user for <a href='https://bsky.social/'>Bluesky</a>. To bridge your fediverse account to Bluesky, follow this account or reply <em>yes</em> when it promps you with a DM. <a href='https://fed.brid.gy/docs'>More info here.</a>",
|
||||
"name": "Bridgy Fed",
|
||||
"attachment": [{
|
||||
"name": "Web site",
|
||||
|
|
|
@ -495,7 +495,7 @@ class ActivityPubTest(TestCase):
|
|||
activitypub._INSTANCE_ACTOR = testutil.global_user
|
||||
self.addCleanup(reset_instance_actor)
|
||||
|
||||
actor_as2 = json_loads(util.read('static/instance-actor.as2.json'))
|
||||
actor_as2 = json_loads(util.read('fed.brid.gy.as2.json'))
|
||||
self.make_user(common.PRIMARY_DOMAIN, cls=Web, obj_as2=actor_as2)
|
||||
|
||||
activitypub._INSTANCE_ACTOR = None
|
||||
|
|
|
@ -2755,8 +2755,7 @@ class WebUtilTest(TestCase):
|
|||
def test_fetch_instance_actor(self, _, __):
|
||||
obj = Object(id=f'https://{common.PRIMARY_DOMAIN}/')
|
||||
self.assertTrue(Web.fetch(obj))
|
||||
self.assertEqual(obj.as2,
|
||||
json_loads(util.read('static/instance-actor.as2.json')))
|
||||
self.assertEqual(obj.as2, json_loads(util.read('fed.brid.gy.as2.json')))
|
||||
|
||||
def test_fetch_resolves_relative_urls(self, mock_get, __):
|
||||
mock_get.return_value = requests_response("""\
|
||||
|
|
11
web.py
11
web.py
|
@ -24,7 +24,7 @@ from requests.auth import HTTPBasicAuth
|
|||
from werkzeug.exceptions import BadGateway, BadRequest, HTTPException, NotFound
|
||||
|
||||
import common
|
||||
from common import add, DOMAIN_RE, SUPERDOMAIN
|
||||
from common import add, DOMAIN_RE, PRIMARY_DOMAIN, PROTOCOL_DOMAINS, SUPERDOMAIN
|
||||
from flask_app import app, cache
|
||||
from ids import translate_handle, translate_object_id, translate_user_id
|
||||
from models import Follower, Object, PROTOCOLS, Target, User
|
||||
|
@ -440,10 +440,11 @@ class Web(User, Protocol):
|
|||
return False
|
||||
|
||||
is_homepage = urlparse(url).path.strip('/') == ''
|
||||
|
||||
if is_homepage and util.domain_from_link(url) == common.PRIMARY_DOMAIN:
|
||||
obj.as2 = json_loads(util.read('static/instance-actor.as2.json'))
|
||||
return True
|
||||
if is_homepage:
|
||||
domain = util.domain_from_link(url)
|
||||
if domain == PRIMARY_DOMAIN or domain in PROTOCOL_DOMAINS:
|
||||
obj.as2 = json_loads(util.read(f'{domain}.as2.json'))
|
||||
return True
|
||||
|
||||
require_backlink = (common.host_url().rstrip('/')
|
||||
if check_backlink and not is_homepage
|
||||
|
|
Ładowanie…
Reference in New Issue