kopia lustrzana https://github.com/snarfed/bridgy-fed
webfinger: add a self link with type application/activity+json
for interop with some fediverse servers like Pleroma (and Akkoma etc) that are unnecessarily picky about which self content type they use from XRD vs JRD. for #995. thanks @qazmlp!pull/1020/head
rodzic
034236f4cf
commit
c345d95b5e
|
@ -3,7 +3,7 @@ import copy
|
|||
from unittest.mock import patch
|
||||
import urllib.parse
|
||||
|
||||
from granary.as2 import CONTENT_TYPE_LD_PROFILE
|
||||
from granary.as2 import CONTENT_TYPE, CONTENT_TYPE_LD_PROFILE
|
||||
from oauth_dropins.webutil import util
|
||||
from oauth_dropins.webutil.testutil import requests_response
|
||||
|
||||
|
@ -43,6 +43,10 @@ WEBFINGER = {
|
|||
'rel': 'self',
|
||||
'type': CONTENT_TYPE_LD_PROFILE,
|
||||
'href': 'http://localhost/user.com',
|
||||
}, {
|
||||
'rel': 'self',
|
||||
'type': CONTENT_TYPE,
|
||||
'href': 'http://localhost/user.com',
|
||||
}, {
|
||||
'rel': 'inbox',
|
||||
'type': CONTENT_TYPE_LD_PROFILE,
|
||||
|
@ -72,6 +76,10 @@ WEBFINGER_NO_HCARD = {
|
|||
'rel': 'self',
|
||||
'type': CONTENT_TYPE_LD_PROFILE,
|
||||
'href': 'https://web.brid.gy/user.com',
|
||||
}, {
|
||||
'rel': 'self',
|
||||
'type': CONTENT_TYPE,
|
||||
'href': 'https://web.brid.gy/user.com',
|
||||
}, {
|
||||
'rel': 'inbox',
|
||||
'type': CONTENT_TYPE_LD_PROFILE,
|
||||
|
@ -96,6 +104,10 @@ WEBFINGER_FAKE = {
|
|||
'rel': 'self',
|
||||
'type': CONTENT_TYPE_LD_PROFILE,
|
||||
'href': 'http://localhost/ap/fa/fake:user',
|
||||
}, {
|
||||
'rel': 'self',
|
||||
'type': CONTENT_TYPE,
|
||||
'href': 'http://localhost/ap/fa/fake:user',
|
||||
}, {
|
||||
'rel': 'inbox',
|
||||
'type': CONTENT_TYPE_LD_PROFILE,
|
||||
|
@ -113,8 +125,8 @@ WEBFINGER_FAKE_FA_BRID_GY = copy.deepcopy(WEBFINGER_FAKE)
|
|||
for link in WEBFINGER_FAKE_FA_BRID_GY['links']:
|
||||
if 'href' in link:
|
||||
link['href'] = link['href'].replace('http://localhost/ap/fa', 'https://fa.brid.gy/ap')
|
||||
WEBFINGER_FAKE_FA_BRID_GY['links'][3]['href'] = 'https://fa.brid.gy/ap/sharedInbox'
|
||||
WEBFINGER_FAKE_FA_BRID_GY['links'][4]['template'] = 'https://fed.brid.gy/fa/fake:handle:user?url={uri}'
|
||||
WEBFINGER_FAKE_FA_BRID_GY['links'][4]['href'] = 'https://fa.brid.gy/ap/sharedInbox'
|
||||
WEBFINGER_FAKE_FA_BRID_GY['links'][5]['template'] = 'https://fed.brid.gy/fa/fake:handle:user?url={uri}'
|
||||
|
||||
|
||||
class HostMetaTest(TestCase):
|
||||
|
|
12
webfinger.py
12
webfinger.py
|
@ -139,12 +139,18 @@ class Webfinger(flask_util.XrdOrJrd):
|
|||
},
|
||||
|
||||
# ActivityPub
|
||||
#
|
||||
# include two self links, one for each AP content type, since some
|
||||
# fediverse servers (eg Pleroma, Akkoma) are unnecessarily picky
|
||||
# about which one they use from XRD vs JRD.
|
||||
# https://github.com/snarfed/bridgy-fed/issues/995
|
||||
{
|
||||
'rel': 'self',
|
||||
'type': as2.CONTENT_TYPE_LD_PROFILE,
|
||||
# WARNING: in python 2 sometimes request.host_url lost port,
|
||||
# http://localhost:8080 would become just http://localhost. no
|
||||
# clue how or why. pay attention here if that happens again.
|
||||
'href': actor_id,
|
||||
}, {
|
||||
'rel': 'self',
|
||||
'type': as2.CONTENT_TYPE,
|
||||
'href': actor_id,
|
||||
}, {
|
||||
# AP reads this and sharedInbox from the AS2 actor, not
|
||||
|
|
Ładowanie…
Reference in New Issue