Hide senstive content and fix image caching
This commit is contained in:
@@ -167,27 +167,26 @@ def admin_tasks() -> _Response:
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route("/admin/lookup", methods=["GET", "POST"])
|
||||
@blueprint.route("/admin/lookup", methods=["GET"])
|
||||
@login_required
|
||||
def admin_lookup() -> _Response:
|
||||
data = None
|
||||
meta = None
|
||||
if request.method == "POST":
|
||||
if request.form.get("url"):
|
||||
data = lookup(request.form.get("url")) # type: ignore
|
||||
if data:
|
||||
if data.has_type(ap.ActivityType.ANNOUNCE):
|
||||
meta = dict(
|
||||
object=data.get_object().to_dict(),
|
||||
object_actor=data.get_object().get_actor().to_dict(),
|
||||
actor=data.get_actor().to_dict(),
|
||||
)
|
||||
if request.args.get("url"):
|
||||
data = lookup(request.args.get("url")) # type: ignore
|
||||
if data:
|
||||
if data.has_type(ap.ActivityType.ANNOUNCE):
|
||||
meta = dict(
|
||||
object=data.get_object().to_dict(),
|
||||
object_actor=data.get_object().get_actor().to_dict(),
|
||||
actor=data.get_actor().to_dict(),
|
||||
)
|
||||
|
||||
elif data.has_type(ap.ActivityType.QUESTION):
|
||||
p.push(data.id, "/task/fetch_remote_question")
|
||||
elif data.has_type(ap.ActivityType.QUESTION):
|
||||
p.push(data.id, "/task/fetch_remote_question")
|
||||
|
||||
print(data)
|
||||
app.logger.debug(data.to_dict())
|
||||
print(data)
|
||||
app.logger.debug(data.to_dict())
|
||||
return render_template(
|
||||
"lookup.html", data=data, meta=meta, url=request.form.get("url")
|
||||
)
|
||||
|
@@ -243,7 +243,7 @@ def task_cache_attachments() -> _Response:
|
||||
iri = task.payload
|
||||
try:
|
||||
activity = ap.fetch_remote_activity(iri)
|
||||
app.logger.info(f"activity={activity!r}")
|
||||
app.logger.info(f"caching attachment for activity={activity!r}")
|
||||
# Generates thumbnails for the actor's icon and the attachments if any
|
||||
|
||||
obj = activity.get_object()
|
||||
@@ -310,13 +310,7 @@ def task_cache_actor() -> _Response:
|
||||
if not activity.has_type([ap.ActivityType.CREATE, ap.ActivityType.ANNOUNCE]):
|
||||
return ""
|
||||
|
||||
if (
|
||||
activity.has_type(ap.ActivityType.CREATE)
|
||||
and activity.get_object()._data.get("attachment", [])
|
||||
) or (
|
||||
activity.has_type(ap.ActivityType.ANNOUNCE)
|
||||
and activity.get_object().has_type(ap.ActivityType.VIDEO)
|
||||
):
|
||||
if activity.get_object()._data.get("attachment", []) or activity.get_object().has_type(ap.ActivityType.VIDEO):
|
||||
Tasks.cache_attachments(iri)
|
||||
|
||||
except (ActivityGoneError, ActivityNotFoundError):
|
||||
|
Reference in New Issue
Block a user