More work towards support moving/deleting instance

This commit is contained in:
Thomas Sileo 2022-09-01 20:42:20 +02:00
parent b03daf1274
commit 5f20eab3f1
7 changed files with 126 additions and 1 deletions

View file

@ -9,6 +9,7 @@ from loguru import logger
from markdown import markdown
from app import config
from app.config import ALSO_KNOWN_AS
from app.config import AP_CONTENT_TYPE # noqa: F401
from app.httpsig import auth
from app.key import get_pubkey_as_pem
@ -126,6 +127,9 @@ ME = {
"tag": _LOCAL_ACTOR_TAGS,
}
if ALSO_KNOWN_AS:
ME["alsoKnownAs"] = [ALSO_KNOWN_AS]
class NotAnObjectError(Exception):
def __init__(self, url: str, resp: httpx.Response | None = None) -> None:

View file

@ -87,6 +87,7 @@ class Config(pydantic.BaseModel):
blocked_servers: list[_BlockedServer] = []
custom_footer: str | None = None
emoji: str | None = None
also_known_as: str | None = None
inbox_retention_days: int = 15
@ -135,6 +136,7 @@ if CONFIG.privacy_replace:
PRIVACY_REPLACE = {pr.domain: pr.replace_by for pr in CONFIG.privacy_replace}
BLOCKED_SERVERS = {blocked_server.hostname for blocked_server in CONFIG.blocked_servers}
ALSO_KNOWN_AS = CONFIG.also_known_as
INBOX_RETENTION_DAYS = CONFIG.inbox_retention_days
CUSTOM_FOOTER = (

View file

@ -251,6 +251,7 @@ async def index(
page: int | None = None,
) -> templates.TemplateResponse | ActivityPubResponse:
if is_activitypub_requested(request):
return ActivityPubResponse(LOCAL_ACTOR.ap_actor)
page = page or 1

View file

@ -29,6 +29,7 @@ async def webfinger(
is_404 = False
resp: httpx.Response | None = None
async with httpx.AsyncClient() as client:
for i, proto in enumerate(protos):
try:
@ -59,7 +60,10 @@ async def webfinger(
if is_404:
return None
return resp.json()
if resp:
return resp.json()
else:
return None
async def get_remote_follow_template(resource: str) -> str | None: