forked from forks/microblog.pub
Tweak/fix webfinger and signed GET
This commit is contained in:
parent
68c13b275d
commit
592de1b22d
6 changed files with 13 additions and 16 deletions
|
@ -113,6 +113,7 @@ async def fetch(url: str, params: dict[str, Any] | None = None) -> RawObject:
|
||||||
},
|
},
|
||||||
params=params,
|
params=params,
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
|
auth=auth,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Special handling for deleted object
|
# Special handling for deleted object
|
||||||
|
|
|
@ -9,7 +9,7 @@ from urllib.parse import urlparse
|
||||||
import bleach
|
import bleach
|
||||||
import emoji
|
import emoji
|
||||||
import html2text
|
import html2text
|
||||||
import timeago # type: ignore
|
import humanize
|
||||||
from bs4 import BeautifulSoup # type: ignore
|
from bs4 import BeautifulSoup # type: ignore
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
|
@ -293,7 +293,7 @@ def _timeago(original_dt: datetime) -> str:
|
||||||
dt = original_dt
|
dt = original_dt
|
||||||
if dt.tzinfo:
|
if dt.tzinfo:
|
||||||
dt = dt.astimezone(timezone.utc).replace(tzinfo=None)
|
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:
|
def _has_media_type(attachment: Attachment, media_type_prefix: str) -> bool:
|
||||||
|
|
|
@ -38,7 +38,9 @@ async def webfinger(
|
||||||
headers={
|
headers={
|
||||||
"User-Agent": config.USER_AGENT,
|
"User-Agent": config.USER_AGENT,
|
||||||
},
|
},
|
||||||
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
resp.raise_for_status()
|
||||||
break
|
break
|
||||||
except httpx.HTTPStatusError as http_error:
|
except httpx.HTTPStatusError as http_error:
|
||||||
logger.exception("HTTP error")
|
logger.exception("HTTP error")
|
||||||
|
|
13
poetry.lock
generated
13
poetry.lock
generated
|
@ -993,14 +993,6 @@ anyio = ">=3.4.0,<5"
|
||||||
[package.extras]
|
[package.extras]
|
||||||
full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests"]
|
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]]
|
[[package]]
|
||||||
name = "tomli"
|
name = "tomli"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
|
@ -1162,7 +1154,7 @@ dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"]
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "1192c7c9d7ce2b93f928406f66c6a6797581bdb4928974679f7b8a0a08a1cf9f"
|
content-hash = "ae7b5b5dfd9a30bc585c27be3d79e48c13b5cbb60b917034bc93e8038c4d3d8f"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
aiosqlite = [
|
aiosqlite = [
|
||||||
|
@ -1968,9 +1960,6 @@ starlette = [
|
||||||
{file = "starlette-0.19.1-py3-none-any.whl", hash = "sha256:5a60c5c2d051f3a8eb546136aa0c9399773a689595e099e0877704d5888279bf"},
|
{file = "starlette-0.19.1-py3-none-any.whl", hash = "sha256:5a60c5c2d051f3a8eb546136aa0c9399773a689595e099e0877704d5888279bf"},
|
||||||
{file = "starlette-0.19.1.tar.gz", hash = "sha256:c6d21096774ecb9639acad41b86b7706e52ba3bf1dc13ea4ed9ad593d47e24c7"},
|
{file = "starlette-0.19.1.tar.gz", hash = "sha256:c6d21096774ecb9639acad41b86b7706e52ba3bf1dc13ea4ed9ad593d47e24c7"},
|
||||||
]
|
]
|
||||||
timeago = [
|
|
||||||
{file = "timeago-1.0.15.tar.gz", hash = "sha256:cfce420d82892af6b2439d0f69eeb3e876bbeddab6670c3c88ebf7676407bf4c"},
|
|
||||||
]
|
|
||||||
tomli = [
|
tomli = [
|
||||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||||
|
|
|
@ -16,7 +16,6 @@ itsdangerous = "^2.1.2"
|
||||||
python-multipart = "^0.0.5"
|
python-multipart = "^0.0.5"
|
||||||
tomli = "^2.0.1"
|
tomli = "^2.0.1"
|
||||||
httpx = "^0.23.0"
|
httpx = "^0.23.0"
|
||||||
timeago = "^1.0.15"
|
|
||||||
SQLAlchemy = {extras = ["asyncio"], version = "^1.4.39"}
|
SQLAlchemy = {extras = ["asyncio"], version = "^1.4.39"}
|
||||||
alembic = "^1.8.0"
|
alembic = "^1.8.0"
|
||||||
bleach = "^5.0.0"
|
bleach = "^5.0.0"
|
||||||
|
|
8
tasks.py
8
tasks.py
|
@ -125,7 +125,13 @@ def configuration_wizard(ctx):
|
||||||
run("PYTHONPATH=. poetry run python scripts/config_wizard.py", pty=True, echo=True)
|
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):
|
def update(ctx):
|
||||||
# type: (Context) -> None
|
# type: (Context) -> None
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
Loading…
Reference in a new issue