Fix attachment display and tweak actor lookup

This commit is contained in:
Thomas Sileo
2019-10-22 20:32:12 +02:00
parent bc7a8db640
commit afa33b4e7c
3 changed files with 46 additions and 4 deletions

View File

@@ -191,11 +191,32 @@ def admin_tasks() -> _Response:
def admin_lookup() -> _Response:
data = None
meta = None
follower = None
following = None
if request.args.get("url"):
data = lookup(request.args.get("url")) # type: ignore
if data:
if not data.has_type(ap.ACTOR_TYPES):
meta = _meta(data)
else:
follower = find_one_activity(
{
"box": "inbox",
"type": ap.ActivityType.FOLLOW.value,
"meta.actor_id": data.id,
"meta.undo": False,
}
)
following = find_one_activity(
{
**by_type(ap.ActivityType.FOLLOW),
**by_object_id(data.id),
**not_undo(),
**in_outbox(),
**follow_request_accepted(),
}
)
if data.has_type(ap.ActivityType.QUESTION):
p.push(data.id, "/task/fetch_remote_question")
@@ -203,7 +224,12 @@ def admin_lookup() -> _Response:
app.logger.debug(data.to_dict())
return htmlify(
render_template(
"lookup.html", data=data, meta=meta, url=request.args.get("url")
"lookup.html",
data=data,
meta=meta,
follower=follower,
following=following,
url=request.args.get("url"),
)
)