AP: stop using PROTOCOLS in inbox URL routes

for #486
pull/729/head
Ryan Barrett 2023-11-15 13:19:37 -08:00
rodzic 507cb19c32
commit 59c6d44f6d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 16 dodań i 8 usunięć

Wyświetl plik

@ -33,7 +33,7 @@ from common import (
subdomain_wrap,
unwrap,
)
from models import Follower, Object, PROTOCOLS, User
from models import Follower, Object, User
from protocol import Protocol
import webfinger
@ -841,10 +841,10 @@ def actor(handle_or_id):
# source protocol in subdomain
@app.post(f'/ap/<id>/inbox')
# source protocol in path; primarily for backcompat
@app.post(f'/ap/<any({",".join(PROTOCOLS)}):protocol>/<id>/inbox')
@app.post(f'/ap/<protocol>/<id>/inbox')
# special case Web users without /ap/web/ prefix, for backward compatibility
@app.post('/inbox', defaults={'protocol': 'web'})
@app.post(f'/<regex("{DOMAIN_RE}"):id>/inbox', defaults={'protocol': 'web'})
@app.post('/inbox')
@app.post(f'/<regex("{DOMAIN_RE}"):id>/inbox')
def inbox(protocol=None, id=None):
"""Handles ActivityPub inbox delivery."""
# parse and validate AS2 activity

16
app.py
Wyświetl plik

@ -6,10 +6,18 @@ registered.
from flask_app import app
# import all modules to register their Flask handlers
import atproto, convert, follow, pages, redirect, superfeedr, ui, webfinger, web
# import after others because it has URL routes that use PROTOCOLS
# TODO: figure out a better way
import activitypub
import (
activitypub,
atproto,
convert,
follow,
pages,
redirect,
superfeedr,
ui,
webfinger,
web,
)
import models
models.reset_protocol_properties()