Copy over the content warning when replying

This commit is contained in:
Thomas Sileo 2022-08-01 20:37:08 +02:00
parent 3fc6ac19f4
commit 9f3956db67
3 changed files with 8 additions and 1 deletions

View File

@ -136,6 +136,7 @@ async def admin_new(
db_session: AsyncSession = Depends(get_db_session),
) -> templates.TemplateResponse:
content = ""
content_warning = None
in_reply_to_object = None
if in_reply_to:
in_reply_to_object = await boxes.get_anybox_object_by_ap_id(
@ -152,6 +153,10 @@ async def admin_new(
mentioned_actor = await fetch_actor(db_session, tag["href"])
content += f"{mentioned_actor.handle} "
# Copy the content warning if any
if in_reply_to_object.summary:
content_warning = in_reply_to_object.summary
return await templates.render_template(
db_session,
request,
@ -159,6 +164,7 @@ async def admin_new(
{
"in_reply_to_object": in_reply_to_object,
"content": content,
"content_warning": content_warning,
"visibility_choices": [
(v.name, ap.VisibilityEnum.get_display_name(v))
for v in ap.VisibilityEnum

View File

@ -76,6 +76,7 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac
# TODO(ts):
#
# Next:
# - allow to manually approve follow requests
# - prevent double accept/double follow
# - UI support for updating posts
# - indieauth tweaks

View File

@ -75,7 +75,7 @@
{% endif %}
<p>
<input type="text" name="content_warning" placeholder="content warning (will mark the post as sensitive)" style="width:95%;">
<input type="text" name="content_warning" placeholder="content warning (will mark the post as sensitive)"{% if content_warning %} value="{{ content_warning }}"{% endif %} style="width:95%;">
</p>
<p>
<input type="checkbox" name="is_sensitive" id="is_sensitive"> <label for="is_sensitive">Mark attachment(s) as sensitive</label>