Make explicit submission flag behavior.

Main intention is to allow API users (bots) to benefit from the
defaults typically enforced clientside, and to generally be clearer
about what values do what.
master
Snakes 2022-11-11 00:21:18 -05:00
parent ee42d470dd
commit 439b73d6ae
Signed by: Snakes
GPG Key ID: E745A82778055C7E
2 changed files with 14 additions and 13 deletions

View File

@ -764,14 +764,14 @@ def submit_post(v, sub=None):
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: return error(f"Submission body_html too long! (max {POST_BODY_HTML_LENGTH_LIMIT} characters)") if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: return error(f"Submission body_html too long! (max {POST_BODY_HTML_LENGTH_LIMIT} characters)")
club = False flag_notify = (request.values.get("notify", "on") == "on")
if FEATURES['COUNTRY_CLUB']: flag_new = request.values.get("new", False, bool)
club = bool(request.values.get("club","")) flag_over_18 = request.values.get("over_18", False, bool)
flag_private = request.values.get("private", False, bool)
flag_club = (request.values.get("club", False, bool) and FEATURES['COUNTRY_CLUB'])
flag_ghost = request.values.get("ghost", False, bool)
if embed and len(embed) > 1500: embed = None if embed and len(embed) > 1500: embed = None
ghost = bool(request.values.get("ghost"))
if embed: embed = embed.strip() if embed: embed = embed.strip()
if url and url.startswith(SITE_FULL): if url and url.startswith(SITE_FULL):
@ -781,12 +781,12 @@ def submit_post(v, sub=None):
sub = 'chudrama' sub = 'chudrama'
post = Submission( post = Submission(
private=bool(request.values.get("private","")), private=flag_private,
notify=bool(request.values.get("notify","")), notify=flag_notify,
club=club, club=flag_club,
author_id=v.id, author_id=v.id,
over_18=bool(request.values.get("over_18","")), over_18=flag_over_18,
new=bool(request.values.get("new","")), new=flag_new,
app_id=v.client.application.id if v.client else None, app_id=v.client.application.id if v.client else None,
is_bot=(v.client is not None), is_bot=(v.client is not None),
url=url, url=url,
@ -796,7 +796,7 @@ def submit_post(v, sub=None):
title=title, title=title,
title_html=title_html, title_html=title_html,
sub=sub, sub=sub,
ghost=ghost ghost=flag_ghost
) )
g.db.add(post) g.db.add(post)

View File

@ -91,6 +91,7 @@
<div class="custom-control custom-checkbox"> <div class="custom-control custom-checkbox">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="post-notify" name="notify" onchange="savetext()" checked> <input autocomplete="off" type="checkbox" class="custom-control-input" id="post-notify" name="notify" onchange="savetext()" checked>
<input type="hidden" name="notify" value="off">
<label class="custom-control-label" for="post-notify">Notify followers</label> <label class="custom-control-label" for="post-notify">Notify followers</label>
</div> </div>