feat/show public object
fix outbox public id
This commit is contained in:
parent
280d74b4e9
commit
ea07507e56
2 changed files with 32 additions and 3 deletions
|
@ -275,7 +275,7 @@ async def _send_create(
|
|||
visibility: ap.VisibilityEnum,
|
||||
published: str | None = None,
|
||||
) -> bool:
|
||||
object_id = build_object_id(allocate_outbox_id())
|
||||
object_id = allocate_outbox_id()
|
||||
if not published:
|
||||
published = now().replace(microsecond=0).isoformat().replace("+00:00", "Z")
|
||||
|
||||
|
@ -291,7 +291,7 @@ async def _send_create(
|
|||
ap_object = {
|
||||
"@context": ap.AS_EXTENDED_CTX,
|
||||
"type": ap_type,
|
||||
"id": object_id,
|
||||
"id": build_object_id(object_id),
|
||||
"attributedTo": ID,
|
||||
"content": content,
|
||||
"to": to,
|
||||
|
@ -299,7 +299,7 @@ async def _send_create(
|
|||
"published": published,
|
||||
# "context": context,
|
||||
# "conversation": context,
|
||||
"url": object_id,
|
||||
"url": build_object_id(object_id),
|
||||
"tag": [],
|
||||
"summary": None,
|
||||
"inReplyTo": None,
|
||||
|
|
29
app/main.py
29
app/main.py
|
@ -29,6 +29,10 @@ from app.database import AsyncSession
|
|||
from app.database import get_db_session
|
||||
from app.boxes import save_incoming
|
||||
|
||||
from sqlalchemy import select
|
||||
from app import models
|
||||
|
||||
|
||||
def _check_0rtt_early_data(request: Request) -> None:
|
||||
"""Disable TLS1.3 0-RTT requests for non-GET."""
|
||||
if request.headers.get("Early-Data", None) == "1" and request.method != "GET":
|
||||
|
@ -42,6 +46,10 @@ logger.remove()
|
|||
logger.add(sys.stdout, level="DEBUG" if DEBUG else "INFO")
|
||||
logger.add("output.log", level="DEBUG")
|
||||
|
||||
class ActivityPubResponse(JSONResponse):
|
||||
media_type = "application/activity+json"
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def index():
|
||||
return ME
|
||||
|
@ -60,6 +68,27 @@ async def inbox(
|
|||
else:
|
||||
return Response(status_code=406)
|
||||
|
||||
|
||||
@app.get("/tail/{public_id}")
|
||||
async def outbox_activity_by_public_id(
|
||||
public_id: str,
|
||||
request: Request,
|
||||
db_session: AsyncSession = Depends(get_db_session),
|
||||
) -> ActivityPubResponse:
|
||||
outbox_object = (
|
||||
await db_session.execute(
|
||||
select(models.OutboxObject).where(
|
||||
models.OutboxObject.public_id == public_id,
|
||||
models.OutboxObject.is_deleted.is_(False),
|
||||
)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
if not outbox_object:
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
return ActivityPubResponse(outbox_object.ap_object)
|
||||
|
||||
|
||||
@app.get("/.well-known/webfinger")
|
||||
async def wellknown_webfinger(resource: str) -> JSONResponse:
|
||||
"""Exposes/servers WebFinger data."""
|
||||
|
|
Loading…
Reference in a new issue