mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 13:14:28 +00:00
Start working on post visibility
This commit is contained in:
parent
5effab8b90
commit
6ab59d2e41
2 changed files with 30 additions and 5 deletions
30
app.py
30
app.py
|
@ -1532,6 +1532,7 @@ def admin_new():
|
|||
reply=reply_id,
|
||||
content=content,
|
||||
thread=thread,
|
||||
visibility=ap.Visibility,
|
||||
emojis=EMOJIS.split(" "),
|
||||
)
|
||||
|
||||
|
@ -1995,22 +1996,41 @@ def api_new_note():
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
visibility = ap.Visibility[
|
||||
_user_api_arg("visibility", default=ap.Visibility.PUBLIC.name)
|
||||
]
|
||||
|
||||
content, tags = parse_markdown(source)
|
||||
to = request.args.get("to")
|
||||
cc = [ID + "/followers"]
|
||||
|
||||
to, cc = [], []
|
||||
if visibility == ap.Visibility.PUBLIC:
|
||||
to = [ap.AS_PUBLIC]
|
||||
cc = [ID + "/followers"]
|
||||
elif visibility == ap.Visibility.UNLISTED:
|
||||
to = [ID + "/followers"]
|
||||
cc = [ap.AS_PUBLIC]
|
||||
elif visibility == ap.Visibility.FOLLOWERS_ONLY:
|
||||
to = [ID + "/followers"]
|
||||
cc = []
|
||||
|
||||
if _reply:
|
||||
reply = ap.fetch_remote_activity(_reply)
|
||||
cc.append(reply.attributedTo)
|
||||
if visibility == ap.Visibility.DIRECT:
|
||||
to.append(reply.attributedTo)
|
||||
else:
|
||||
cc.append(reply.attributedTo)
|
||||
|
||||
for tag in tags:
|
||||
if tag["type"] == "Mention":
|
||||
cc.append(tag["href"])
|
||||
if visibility == ap.Visibility.DIRECT:
|
||||
to.append(tag["href"])
|
||||
else:
|
||||
cc.append(tag["href"])
|
||||
|
||||
raw_note = dict(
|
||||
attributedTo=MY_PERSON.id,
|
||||
cc=list(set(cc)),
|
||||
to=[to if to else ap.AS_PUBLIC],
|
||||
to=list(set(to)),
|
||||
content=content,
|
||||
tag=tags,
|
||||
source={"mediaType": "text/markdown", "content": source},
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
<form action="/api/new_{% if request.args.get("question") == "1" %}question{%else%}note{%endif%}" method="POST" enctype="multipart/form-data">
|
||||
<input type="hidden" name="redirect" value="/">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<select name="visibility">
|
||||
{% for v in visibility %}
|
||||
<option value="{{v.name}}">{{ v.value }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
|
||||
|
||||
<p>
|
||||
|
|
Loading…
Reference in a new issue