Tweak/fix webfinger and signed GET

This commit is contained in:
Thomas Sileo 2022-07-08 12:10:20 +02:00
parent 68c13b275d
commit 592de1b22d
6 changed files with 13 additions and 16 deletions

View file

@ -113,6 +113,7 @@ async def fetch(url: str, params: dict[str, Any] | None = None) -> RawObject:
},
params=params,
follow_redirects=True,
auth=auth,
)
# Special handling for deleted object

View file

@ -9,7 +9,7 @@ from urllib.parse import urlparse
import bleach
import emoji
import html2text
import timeago # type: ignore
import humanize
from bs4 import BeautifulSoup # type: ignore
from fastapi import Request
from fastapi.templating import Jinja2Templates
@ -293,7 +293,7 @@ def _timeago(original_dt: datetime) -> str:
dt = original_dt
if dt.tzinfo:
dt = dt.astimezone(timezone.utc).replace(tzinfo=None)
return timeago.format(dt, now().replace(tzinfo=None))
return humanize.naturaltime(dt, when=now().replace(tzinfo=None))
def _has_media_type(attachment: Attachment, media_type_prefix: str) -> bool:

View file

@ -38,7 +38,9 @@ async def webfinger(
headers={
"User-Agent": config.USER_AGENT,
},
follow_redirects=True,
)
resp.raise_for_status()
break
except httpx.HTTPStatusError as http_error:
logger.exception("HTTP error")