kopia lustrzana https://gitlab.com/jaywink/federation
Improve webfinger handling of AP application type.
rodzic
47bf0f579d
commit
f1bb3544fa
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
from typing import Optional, Any
|
from typing import Optional, Any
|
||||||
|
|
||||||
from federation.protocols.activitypub.signing import get_http_authentication
|
from federation.protocols.activitypub.signing import get_http_authentication
|
||||||
|
@ -15,6 +16,7 @@ except Exception as exc:
|
||||||
federation_user = None
|
federation_user = None
|
||||||
logger.warning("django is required for get requests signing: %s", exc)
|
logger.warning("django is required for get requests signing: %s", exc)
|
||||||
|
|
||||||
|
type_path = re.compile(r'^application/(activity|ld)\+json')
|
||||||
|
|
||||||
def get_profile_id_from_webfinger(handle: str) -> Optional[str]:
|
def get_profile_id_from_webfinger(handle: str) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
|
@ -29,7 +31,7 @@ def get_profile_id_from_webfinger(handle: str) -> Optional[str]:
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return
|
return
|
||||||
for link in doc.get("links", []):
|
for link in doc.get("links", []):
|
||||||
if link.get("rel") == "self" and link.get("type") == "application/activity+json":
|
if link.get("rel") == "self" and type_path.match(link.get("type")):
|
||||||
return link["href"]
|
return link["href"]
|
||||||
logger.debug("get_profile_id_from_webfinger: found webfinger but it has no as2 self href")
|
logger.debug("get_profile_id_from_webfinger: found webfinger but it has no as2 self href")
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue