Hide senstive content and fix image caching

This commit is contained in:
Thomas Sileo 2019-08-15 17:09:17 +02:00
parent 043e9a79dc
commit e5d8ef83ea
5 changed files with 46 additions and 27 deletions

View file

@ -167,14 +167,13 @@ 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 request.args.get("url"):
data = lookup(request.args.get("url")) # type: ignore
if data:
if data.has_type(ap.ActivityType.ANNOUNCE):
meta = dict(

View file

@ -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):

View file

@ -295,6 +295,20 @@ a:hover {
background: inherit;
cursor: default;
}
.bar-item-reverse {
background: $primary-color;
color: $background-color;
padding: 5px;
margin-right: 10px;
float: left;
border-radius:2px;
border: 0;
}
.bar-item-reverse:hover {
background: $color-menu-background;
color: $color-light;
}
button.bar-item {
border: 0
}

View file

@ -6,10 +6,9 @@
{% include "header.html" %}
<div style="margin-top:50px;">
<form id="lookup-form" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<form id="lookup-form" method="GET">
<input type="text" name="url" value="{{url or '' }}" placeholder="https://url-of-a-user-or-a-note.tld">
<input type="submit" value="Lookup">
<input type="submit" value="Lookup">
</form>
{% if data %}

View file

@ -151,6 +151,17 @@
{% if obj.attachment and obj | has_type('Note') %}
<div style="padding:20px 0;">
{% if obj.sensitive and not request.args.get("show_sensitive") == perma_id %}
<div style="clear:both">
<form action="{{redir}}" class="action-form" method="GET" style="display:inline-block">
<input type="hidden" name="show_sensitive" value="{{perma_id}}">
<input type="hidden" name="url" value="{{obj.id}}">
<button type="submit" class="bar-item-reverse">display sensitive content</button>
</form>
</div>
{% else %}
{% if obj.attachment | not_only_imgs %}
<h3 class="l">Attachments</h3>
<ul style="padding:0;">
@ -167,6 +178,8 @@
{% if obj.attachment | not_only_imgs %}
</ul>
{% endif %}
{% endif %}
</div>
{% endif %}