mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-14 18:54:27 +00:00
Better default post visibility
This commit is contained in:
parent
ab01fed24a
commit
4d968264f2
2 changed files with 9 additions and 1 deletions
|
@ -296,6 +296,7 @@ def admin_new() -> _Response:
|
|||
content = ""
|
||||
thread: List[Any] = []
|
||||
print(request.args)
|
||||
default_visibility = None # ap.Visibility.PUBLIC
|
||||
if request.args.get("reply"):
|
||||
data = DB.activities.find_one({"activity.object.id": request.args.get("reply")})
|
||||
if data:
|
||||
|
@ -308,10 +309,16 @@ def admin_new() -> _Response:
|
|||
),
|
||||
)
|
||||
reply = ap.parse_activity(data["activity"]["object"])
|
||||
# Fetch the post visibility, in case it's follower only
|
||||
default_visibility = ap.get_visibility(reply)
|
||||
# If it's public, we default the reply to unlisted
|
||||
if default_visibility == ap.Visibility.PUBLIC:
|
||||
default_visibility = ap.Visibility.UNLISTED
|
||||
|
||||
reply_id = reply.id
|
||||
if reply.ACTIVITY_TYPE == ap.ActivityType.CREATE:
|
||||
reply_id = reply.get_object().id
|
||||
|
||||
actor = reply.get_actor()
|
||||
domain = urlparse(actor.id).netloc
|
||||
# FIXME(tsileo): if reply of reply, fetch all participants
|
||||
|
@ -324,6 +331,7 @@ def admin_new() -> _Response:
|
|||
reply=reply_id,
|
||||
content=content,
|
||||
thread=thread,
|
||||
default_visibility=default_visibility,
|
||||
visibility=ap.Visibility,
|
||||
emojis=config.EMOJIS.split(" "),
|
||||
custom_emojis={
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<select name="visibility" style="padding:8px 10px;">
|
||||
{% for v in visibility %}
|
||||
<option value="{{v.name}}">{{ v.value }}</option>
|
||||
<option value="{{v.name}}" {% if v == default_visibility %}selected="selected"{% endif %}>{{ v.value }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
|
||||
|
|
Loading…
Reference in a new issue