diff --git a/blueprints/admin.py b/blueprints/admin.py index 79993df..ed65c15 100644 --- a/blueprints/admin.py +++ b/blueprints/admin.py @@ -207,6 +207,49 @@ def admin_lookup() -> _Response: ) +@blueprint.route("/admin/profile", methods=["GET"]) +@login_required +def admin_profile() -> _Response: + if not request.args.get("actor_id"): + abort(404) + + actor_id = request.args.get("actor_id") + actor = ap.fetch_remote_activity(actor_id) + q = { + "meta.actor_id": actor_id, + "box": "inbox", + "type": {"$in": [ap.ActivityType.CREATE.value, ap.ActivityType.ANNOUNCE.value]}, + } + inbox_data, older_than, newer_than = paginated_query( + DB.activities, q, limit=int(request.args.get("limit", 25)) + ) + follower = find_one_activity( + { + "box": "inbox", + "type": ap.ActivityType.FOLLOW.value, + "meta.actor_id": actor.id, + "meta.undo": False, + } + ) + following = find_one_activity( + {"type": ap.ActivityType.ACCEPT.value, "meta.actor_id": actor.id} + ) + + return htmlify( + render_template( + "stream.html", + actor_id=actor_id, + actor=actor.to_dict(), + inbox_data=inbox_data, + older_than=older_than, + newer_than=newer_than, + follower=follower, + following=following, + lists=list(DB.lists.find()), + ) + ) + + @blueprint.route("/admin/thread") @login_required def admin_thread() -> _Response: diff --git a/templates/stream.html b/templates/stream.html index eccb207..2e71f45 100644 --- a/templates/stream.html +++ b/templates/stream.html @@ -17,6 +17,101 @@ {% endif %} +{% if actor %} +{% set actor_redir = request.path + "?actor_id=" + request.args.get('actor_id') %} + +
+
+ {% if follower %}follows you!{% endif %} + +{% if following %} +
+ + + + +
+
+ + + + +
+ + +{% if lists %} +
+ + + + + +
+{% endif %} + +{% for l in lists %} +{% if actor.id in l.members %} +
+ + + + +
+ + +{% endif %} +{% endfor %} + + + + +{% else %} +
+ + + + +
+
+ + + + +
+ + +{% endif %} +
+ + + +{% if not actor.icon %} + +{% else %} +{% endif %} + +
+
{{ (actor.name or actor.preferredUsername) | clean | replace_custom_emojis(actor) | safe }}
+@{{ actor.preferredUsername }}@{{ actor | url_or_id | get_url | domain }} +
+
+ +{% if actor.summary %} +
+ {{ actor.summary | clean | replace_custom_emojis(actor) | safe }} +
+{% endif %} +
+ +{% endif %} +
{% for item in inbox_data %} {% if 'actor' in item.meta %} diff --git a/templates/utils.html b/templates/utils.html index 10a2303..3b8285d 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -322,8 +322,8 @@ -{% endif %} +profile +{% endif %} {% endif %} diff --git a/utils/template_filters.py b/utils/template_filters.py index 0e42231..4467a24 100644 --- a/utils/template_filters.py +++ b/utils/template_filters.py @@ -99,8 +99,6 @@ ALLOWED_TAGS = [ @filters.app_template_filter() def replace_custom_emojis(content, note): - print("\n" * 50) - print("custom_replace", note) idx = {} for tag in note.get("tag", []): if tag.get("type") == "Emoji":