mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 13:14:28 +00:00
Hide senstive content and fix image caching
This commit is contained in:
parent
043e9a79dc
commit
e5d8ef83ea
5 changed files with 46 additions and 27 deletions
|
@ -167,27 +167,26 @@ def admin_tasks() -> _Response:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/admin/lookup", methods=["GET", "POST"])
|
@blueprint.route("/admin/lookup", methods=["GET"])
|
||||||
@login_required
|
@login_required
|
||||||
def admin_lookup() -> _Response:
|
def admin_lookup() -> _Response:
|
||||||
data = None
|
data = None
|
||||||
meta = None
|
meta = None
|
||||||
if request.method == "POST":
|
if request.args.get("url"):
|
||||||
if request.form.get("url"):
|
data = lookup(request.args.get("url")) # type: ignore
|
||||||
data = lookup(request.form.get("url")) # type: ignore
|
if data:
|
||||||
if data:
|
if data.has_type(ap.ActivityType.ANNOUNCE):
|
||||||
if data.has_type(ap.ActivityType.ANNOUNCE):
|
meta = dict(
|
||||||
meta = dict(
|
object=data.get_object().to_dict(),
|
||||||
object=data.get_object().to_dict(),
|
object_actor=data.get_object().get_actor().to_dict(),
|
||||||
object_actor=data.get_object().get_actor().to_dict(),
|
actor=data.get_actor().to_dict(),
|
||||||
actor=data.get_actor().to_dict(),
|
)
|
||||||
)
|
|
||||||
|
|
||||||
elif data.has_type(ap.ActivityType.QUESTION):
|
elif data.has_type(ap.ActivityType.QUESTION):
|
||||||
p.push(data.id, "/task/fetch_remote_question")
|
p.push(data.id, "/task/fetch_remote_question")
|
||||||
|
|
||||||
print(data)
|
print(data)
|
||||||
app.logger.debug(data.to_dict())
|
app.logger.debug(data.to_dict())
|
||||||
return render_template(
|
return render_template(
|
||||||
"lookup.html", data=data, meta=meta, url=request.form.get("url")
|
"lookup.html", data=data, meta=meta, url=request.form.get("url")
|
||||||
)
|
)
|
||||||
|
|
|
@ -243,7 +243,7 @@ def task_cache_attachments() -> _Response:
|
||||||
iri = task.payload
|
iri = task.payload
|
||||||
try:
|
try:
|
||||||
activity = ap.fetch_remote_activity(iri)
|
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
|
# Generates thumbnails for the actor's icon and the attachments if any
|
||||||
|
|
||||||
obj = activity.get_object()
|
obj = activity.get_object()
|
||||||
|
@ -310,13 +310,7 @@ def task_cache_actor() -> _Response:
|
||||||
if not activity.has_type([ap.ActivityType.CREATE, ap.ActivityType.ANNOUNCE]):
|
if not activity.has_type([ap.ActivityType.CREATE, ap.ActivityType.ANNOUNCE]):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
if (
|
if activity.get_object()._data.get("attachment", []) or activity.get_object().has_type(ap.ActivityType.VIDEO):
|
||||||
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)
|
|
||||||
):
|
|
||||||
Tasks.cache_attachments(iri)
|
Tasks.cache_attachments(iri)
|
||||||
|
|
||||||
except (ActivityGoneError, ActivityNotFoundError):
|
except (ActivityGoneError, ActivityNotFoundError):
|
||||||
|
|
|
@ -295,6 +295,20 @@ a:hover {
|
||||||
background: inherit;
|
background: inherit;
|
||||||
cursor: default;
|
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 {
|
button.bar-item {
|
||||||
border: 0
|
border: 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
{% include "header.html" %}
|
{% include "header.html" %}
|
||||||
<div style="margin-top:50px;">
|
<div style="margin-top:50px;">
|
||||||
|
|
||||||
<form id="lookup-form" method="POST">
|
<form id="lookup-form" method="GET">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
<input type="text" name="url" value="{{url or '' }}" placeholder="https://url-of-a-user-or-a-note.tld">
|
||||||
<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>
|
</form>
|
||||||
|
|
||||||
{% if data %}
|
{% if data %}
|
||||||
|
|
|
@ -151,6 +151,17 @@
|
||||||
|
|
||||||
{% if obj.attachment and obj | has_type('Note') %}
|
{% if obj.attachment and obj | has_type('Note') %}
|
||||||
<div style="padding:20px 0;">
|
<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 %}
|
{% if obj.attachment | not_only_imgs %}
|
||||||
<h3 class="l">Attachments</h3>
|
<h3 class="l">Attachments</h3>
|
||||||
<ul style="padding:0;">
|
<ul style="padding:0;">
|
||||||
|
@ -167,6 +178,8 @@
|
||||||
{% if obj.attachment | not_only_imgs %}
|
{% if obj.attachment | not_only_imgs %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue