mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-14 02:34:27 +00:00
Allow to post note with attachments and a CW
This commit is contained in:
parent
356aace9bc
commit
0f20a1d12f
2 changed files with 19 additions and 2 deletions
15
app/admin.py
15
app/admin.py
|
@ -1021,7 +1021,7 @@ async def admin_actions_unpin(
|
|||
async def admin_actions_new(
|
||||
request: Request,
|
||||
files: list[UploadFile] = [],
|
||||
content: str = Form(),
|
||||
content: str | None = Form(None),
|
||||
redirect_url: str = Form(),
|
||||
in_reply_to: str | None = Form(None),
|
||||
content_warning: str | None = Form(None),
|
||||
|
@ -1032,6 +1032,19 @@ async def admin_actions_new(
|
|||
csrf_check: None = Depends(verify_csrf_token),
|
||||
db_session: AsyncSession = Depends(get_db_session),
|
||||
) -> RedirectResponse:
|
||||
if not content and not content_warning:
|
||||
raise HTTPException(status_code=422, detail="Error: object must have a content")
|
||||
|
||||
# Do like Mastodon, if there's only a CW with no content and some attachments,
|
||||
# swap the CW and the content
|
||||
if not content and content_warning and len(files) >= 1:
|
||||
content = content_warning
|
||||
is_sensitive = True
|
||||
content_warning = None
|
||||
|
||||
if not content:
|
||||
raise HTTPException(status_code=422, detail="Error: objec must have a content")
|
||||
|
||||
# XXX: for some reason, no files restuls in an empty single file
|
||||
uploads = []
|
||||
raw_form_data = await request.form()
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
{% block head %}
|
||||
{% if outbox_object %}
|
||||
{% set excerpt = outbox_object.content | html2text | trim | truncate(50) %}
|
||||
{% if outbox_object.content %}
|
||||
{% set excerpt = outbox_object.content | html2text | trim | truncate(50) %}
|
||||
{% else %}
|
||||
{% set excerpt = outbox_object.summary | html2text | trim | truncate(50) %}
|
||||
{% endif %}
|
||||
<title>{% if outbox_object.name %}{{ outbox_object.name }}{% else %}{{ local_actor.display_name }}: "{{ excerpt }}"{% endif %}</title>
|
||||
<link rel="webmention" href="{{ url_for("webmention_endpoint") }}">
|
||||
<link rel="alternate" href="{{ request.url }}" type="application/activity+json">
|
||||
|
|
Loading…
Reference in a new issue