mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -08:00
Lemmy v0.19.4 has changed to nodeinfo v2.1
This commit is contained in:
parent
3f28c20d1e
commit
95f6475792
2 changed files with 11 additions and 4 deletions
|
@ -1203,8 +1203,9 @@ def new_instance_profile_task(instance_id: int):
|
||||||
nodeinfo_json = nodeinfo.json()
|
nodeinfo_json = nodeinfo.json()
|
||||||
for links in nodeinfo_json['links']:
|
for links in nodeinfo_json['links']:
|
||||||
if 'rel' in links and (
|
if 'rel' in links and (
|
||||||
links['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0' or
|
links['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0' or # most platforms except KBIN and Lemmy v0.19.4
|
||||||
links['rel'] == 'https://nodeinfo.diaspora.software/ns/schema/2.0'):
|
links['rel'] == 'https://nodeinfo.diaspora.software/ns/schema/2.0' or # KBIN
|
||||||
|
links['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.1'): # Lemmy v0.19.4 (no 2.0 back-compat provided here)
|
||||||
try:
|
try:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
node = requests.get(links['href'], headers=HEADERS, timeout=5,
|
node = requests.get(links['href'], headers=HEADERS, timeout=5,
|
||||||
|
@ -1216,6 +1217,7 @@ def new_instance_profile_task(instance_id: int):
|
||||||
instance.version = node_json['software']['version']
|
instance.version = node_json['software']['version']
|
||||||
instance.nodeinfo_href = links['href']
|
instance.nodeinfo_href = links['href']
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
break # most platforms (except Lemmy v0.19.4) that provide 2.1 also provide 2.0 - there's no need to check both
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -184,7 +184,11 @@ def register(app):
|
||||||
instances = Instance.query.filter(Instance.gone_forever == False, Instance.id != 1).all()
|
instances = Instance.query.filter(Instance.gone_forever == False, Instance.id != 1).all()
|
||||||
HEADERS = {'User-Agent': 'PieFed/1.0', 'Accept': 'application/activity+json'}
|
HEADERS = {'User-Agent': 'PieFed/1.0', 'Accept': 'application/activity+json'}
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
if not instance.nodeinfo_href:
|
nodeinfo_href = instance.nodeinfo_href
|
||||||
|
if instance.software == 'lemmy' and instance.version == '0.19.4' and instance.nodeinfo_href.endswith('nodeinfo/2.0.json'):
|
||||||
|
nodeinfo_href = None # Lemmy v0.19.4 no longer provides .well-known/nodeinfo response for 2.0, and
|
||||||
|
# 'solves' this by redirecting calls for nodeinfo/2.0.json to nodeinfo/2.1
|
||||||
|
if not nodeinfo_href:
|
||||||
try:
|
try:
|
||||||
nodeinfo = requests.get(f"https://{instance.domain}/.well-known/nodeinfo", headers=HEADERS,
|
nodeinfo = requests.get(f"https://{instance.domain}/.well-known/nodeinfo", headers=HEADERS,
|
||||||
timeout=5, allow_redirects=True)
|
timeout=5, allow_redirects=True)
|
||||||
|
@ -194,7 +198,8 @@ def register(app):
|
||||||
for links in nodeinfo_json['links']:
|
for links in nodeinfo_json['links']:
|
||||||
if 'rel' in links and (
|
if 'rel' in links and (
|
||||||
links['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0' or
|
links['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0' or
|
||||||
links['rel'] == 'https://nodeinfo.diaspora.software/ns/schema/2.0'):
|
links['rel'] == 'https://nodeinfo.diaspora.software/ns/schema/2.0' or
|
||||||
|
links['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.1'):
|
||||||
instance.nodeinfo_href = links['href']
|
instance.nodeinfo_href = links['href']
|
||||||
instance.failures = 0
|
instance.failures = 0
|
||||||
instance.dormant = False
|
instance.dormant = False
|
||||||
|
|
Loading…
Add table
Reference in a new issue