Improve privacy relace

This commit is contained in:
Thomas Sileo 2022-08-04 19:11:14 +02:00
parent 6d2db24c33
commit d378e17173
5 changed files with 13 additions and 17 deletions

View file

@ -15,6 +15,7 @@ from app.database import AsyncSession
from app.models import InboxObject
from app.models import OutboxObject
from app.utils.url import is_url_valid
from app.utils.url import make_abs
class OpenGraphMeta(BaseModel):
@ -46,6 +47,10 @@ def _scrap_og_meta(url: str, html: str) -> OpenGraphMeta | None:
if "title" not in raw:
return None
for maybe_rel in {"url", "image"}:
if u := raw.get(maybe_rel):
raw[maybe_rel] = make_abs(u, url)
return OpenGraphMeta.parse_obj(raw)