diff --git a/app/admin.py b/app/admin.py index 830b2c5..c72d3d0 100644 --- a/app/admin.py +++ b/app/admin.py @@ -223,6 +223,53 @@ def get_notifications( ) +@router.get("/object") +def admin_object( + request: Request, + ap_id: str, + db: Session = Depends(get_db), +) -> templates.TemplateResponse: + return templates.render_template( + db, + request, + "admin_object.html", + {}, + ) + + +@router.get("/profile") +def admin_profile( + request: Request, + actor_id: str, + db: Session = Depends(get_db), +) -> templates.TemplateResponse: + actor = db.query(models.Actor).filter(models.Actor.ap_id == actor_id).one_or_none() + if not actor: + raise HTTPException(status_code=404) + + actors_metadata = get_actors_metadata(db, [actor]) + + inbox_objects = ( + db.query(models.InboxObject) + .filter( + models.InboxObject.actor_id == actor.id, + models.InboxObject.ap_type.in_(["Note", "Article", "Video"]), + ) + .all() + ) + + return templates.render_template( + db, + request, + "admin_profile.html", + { + "actors_metadata": actors_metadata, + "actor": actor, + "inbox_objects": inbox_objects, + }, + ) + + @router.post("/actions/follow") def admin_actions_follow( request: Request, diff --git a/app/templates/admin_profile.html b/app/templates/admin_profile.html new file mode 100644 index 0000000..450f074 --- /dev/null +++ b/app/templates/admin_profile.html @@ -0,0 +1,8 @@ +{%- import "utils.html" as utils with context -%} +{% extends "layout.html" %} +{% block content %} + {{ utils.display_actor(actor, actors_metadata) }} + {% for inbox_object in inbox_objects %} + {{ utils.display_object(inbox_object) }} + {% endfor %} +{% endblock %} diff --git a/app/templates/utils.html b/app/templates/utils.html index 1b73aea..59640ed 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -59,6 +59,13 @@ {% endmacro %} +{% macro admin_profile_button(ap_actor_id) %} +
+{% endmacro %} + {% macro display_actor(actor, actors_metadata) %} {% set metadata = actors_metadata.get(actor.ap_id) %}