forked from forks/microblog.pub
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 = ""
|
content = ""
|
||||||
thread: List[Any] = []
|
thread: List[Any] = []
|
||||||
print(request.args)
|
print(request.args)
|
||||||
|
default_visibility = None # ap.Visibility.PUBLIC
|
||||||
if request.args.get("reply"):
|
if request.args.get("reply"):
|
||||||
data = DB.activities.find_one({"activity.object.id": request.args.get("reply")})
|
data = DB.activities.find_one({"activity.object.id": request.args.get("reply")})
|
||||||
if data:
|
if data:
|
||||||
|
@ -308,10 +309,16 @@ def admin_new() -> _Response:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
reply = ap.parse_activity(data["activity"]["object"])
|
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
|
reply_id = reply.id
|
||||||
if reply.ACTIVITY_TYPE == ap.ActivityType.CREATE:
|
if reply.ACTIVITY_TYPE == ap.ActivityType.CREATE:
|
||||||
reply_id = reply.get_object().id
|
reply_id = reply.get_object().id
|
||||||
|
|
||||||
actor = reply.get_actor()
|
actor = reply.get_actor()
|
||||||
domain = urlparse(actor.id).netloc
|
domain = urlparse(actor.id).netloc
|
||||||
# FIXME(tsileo): if reply of reply, fetch all participants
|
# FIXME(tsileo): if reply of reply, fetch all participants
|
||||||
|
@ -324,6 +331,7 @@ def admin_new() -> _Response:
|
||||||
reply=reply_id,
|
reply=reply_id,
|
||||||
content=content,
|
content=content,
|
||||||
thread=thread,
|
thread=thread,
|
||||||
|
default_visibility=default_visibility,
|
||||||
visibility=ap.Visibility,
|
visibility=ap.Visibility,
|
||||||
emojis=config.EMOJIS.split(" "),
|
emojis=config.EMOJIS.split(" "),
|
||||||
custom_emojis={
|
custom_emojis={
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
<select name="visibility" style="padding:8px 10px;">
|
<select name="visibility" style="padding:8px 10px;">
|
||||||
{% for v in visibility %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
|
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue