Tweak/fix webfinger and signed GET

main
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")

13
poetry.lock generated
View File

@ -993,14 +993,6 @@ anyio = ">=3.4.0,<5"
[package.extras]
full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests"]
[[package]]
name = "timeago"
version = "1.0.15"
description = "A very simple python library, used to format datetime with `*** time ago` statement. eg: \"3 hours ago\"."
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "tomli"
version = "2.0.1"
@ -1162,7 +1154,7 @@ dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"]
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "1192c7c9d7ce2b93f928406f66c6a6797581bdb4928974679f7b8a0a08a1cf9f"
content-hash = "ae7b5b5dfd9a30bc585c27be3d79e48c13b5cbb60b917034bc93e8038c4d3d8f"
[metadata.files]
aiosqlite = [
@ -1968,9 +1960,6 @@ starlette = [
{file = "starlette-0.19.1-py3-none-any.whl", hash = "sha256:5a60c5c2d051f3a8eb546136aa0c9399773a689595e099e0877704d5888279bf"},
{file = "starlette-0.19.1.tar.gz", hash = "sha256:c6d21096774ecb9639acad41b86b7706e52ba3bf1dc13ea4ed9ad593d47e24c7"},
]
timeago = [
{file = "timeago-1.0.15.tar.gz", hash = "sha256:cfce420d82892af6b2439d0f69eeb3e876bbeddab6670c3c88ebf7676407bf4c"},
]
tomli = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},

View File

@ -16,7 +16,6 @@ itsdangerous = "^2.1.2"
python-multipart = "^0.0.5"
tomli = "^2.0.1"
httpx = "^0.23.0"
timeago = "^1.0.15"
SQLAlchemy = {extras = ["asyncio"], version = "^1.4.39"}
alembic = "^1.8.0"
bleach = "^5.0.0"

View File

@ -125,7 +125,13 @@ def configuration_wizard(ctx):
run("PYTHONPATH=. poetry run python scripts/config_wizard.py", pty=True, echo=True)
@task(compile_scss, migrate_db)
@task
def install_deps(ctx):
# type: (Context) -> None
run("poetry install", pty=True, echo=True)
@task(install_deps, compile_scss, migrate_db)
def update(ctx):
# type: (Context) -> None
print("Done")