Add new internal profile page for remote actors
This commit is contained in:
parent
3f65368547
commit
3bd2ab8102
4 changed files with 140 additions and 4 deletions
|
@ -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:
|
||||
|
|
|
@ -17,6 +17,101 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if actor %}
|
||||
{% set actor_redir = request.path + "?actor_id=" + request.args.get('actor_id') %}
|
||||
|
||||
<div id="profile" style="margin-bottom:80px;">
|
||||
<div style="clear:both;margin-left:100px;padding-bottom:5px;margin-bottom:15px;display:inline-block;">
|
||||
{% if follower %}<span class="bar-item-no-hover">follows you!</span>{% endif %}
|
||||
|
||||
{% if following %}
|
||||
<form action="/api/undo" class="action-form" method="post">
|
||||
<input type="hidden" name="redirect" value="{{ actor_redir }}"/>
|
||||
<input type="hidden" name="id" value="{{ actor.id }}"/>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="bar-item">unfollow</button>
|
||||
</form>
|
||||
<form action="/api/block" class="action-form" method="POST">
|
||||
<input type="hidden" name="redirect" value="{{ actor_redir }}">
|
||||
<input type="hidden" name="actor" value="{{ actor.id }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="bar-item" onclick="return confirm('Confirm the block action?');">block</button>
|
||||
</form>
|
||||
|
||||
|
||||
{% if lists %}
|
||||
<form action="/api/add_to_list" class="action-form" method="post">
|
||||
<input type="hidden" name="redirect" value="{{ actor_redir }}"/>
|
||||
<input type="hidden" name="actor_id" value="{{ actor.id }}"/>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<select name="list_name" style="float:left;">
|
||||
<option></option>
|
||||
{% for l in lists %}
|
||||
{% if actor.id not in l.members %}
|
||||
<option value="{{l.name}}">{{l.name}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="submit" class="bar-item">add to list</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% for l in lists %}
|
||||
{% if actor.id in l.members %}
|
||||
<form action="/api/remove_from_list" class="action-form" method="post">
|
||||
<input type="hidden" name="redirect" value="{{ actor_redir }}"/>
|
||||
<input type="hidden" name="actor_id" value="{{ actor.id }}"/>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="bar-item">remove from {{ l.name }}</button>
|
||||
</form>
|
||||
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
|
||||
{% else %}
|
||||
<form action="/api/follow" class="action-form" method="POST">
|
||||
<input type="hidden" name="redirect" value="{{ actor_redir }}"/>
|
||||
<input type="hidden" name="actor" value="{{ actor.id }}"/>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="bar-item">follow</button>
|
||||
</form>
|
||||
<form action="/api/block" class="action-form" method="POST">
|
||||
<input type="hidden" name="redirect" value="{{ actor_redir }}">
|
||||
<input type="hidden" name="actor" value="{{ actor.id }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="bar-item" onclick="return confirm('Confirm the block action?');">block</button>
|
||||
</form>
|
||||
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<a class="actor-box" href="{{actor | url_or_id | get_url }}" style="clear:both;">
|
||||
<span style="float:left;padding-right:15px;">
|
||||
{% if not actor.icon %}
|
||||
<img class="actor-icon" src="/static/nopic.png" style="width:80px">
|
||||
{% else %}
|
||||
<img class="actor-icon" src="{{ actor.icon.url | get_actor_icon_url(80) }}" style="width:80px;">{% endif %}
|
||||
</span>
|
||||
<div class="actor-inline">
|
||||
<div style="font-weight:bold">{{ (actor.name or actor.preferredUsername) | clean | replace_custom_emojis(actor) | safe }}</div>
|
||||
<small class="lcolor">@{{ actor.preferredUsername }}@{{ actor | url_or_id | get_url | domain }}</small>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
{% if actor.summary %}
|
||||
<div style="margin-top:70px;margin-bottom:20px;">
|
||||
{{ actor.summary | clean | replace_custom_emojis(actor) | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<div id="notes" style="clear:both;">
|
||||
{% for item in inbox_data %}
|
||||
{% if 'actor' in item.meta %}
|
||||
|
|
|
@ -322,8 +322,8 @@
|
|||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="bar-item" onclick="return confirm('Confirm the block action?');">block</button>
|
||||
</form>
|
||||
<!--<a class="bar-item" href="/admin/profile?id={{actor.id}}">profile</a>
|
||||
-->{% endif %}
|
||||
<a class="bar-item" href="/admin/profile?actor_id={{actor.id}}">profile</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -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":
|
||||
|
|
Loading…
Reference in a new issue