b
This commit is contained in:
parent
24245d95cc
commit
207507fc8e
10 changed files with 97 additions and 279 deletions
|
@ -50,8 +50,6 @@ def settings_profile_post(v):
|
|||
if request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB."}, 413
|
||||
elif request.content_length > 4 * 1024 * 1024: return {"error":"Max file size is 4 MB."}, 413
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
|
||||
updated = False
|
||||
|
||||
|
@ -128,36 +126,28 @@ def settings_profile_post(v):
|
|||
v.bio_html = None
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, msg="Your bio has been updated.")
|
||||
return render_template("settings_profile.html", v=v, msg="Your bio has been updated.")
|
||||
|
||||
elif request.values.get("sig") == "":
|
||||
v.sig = None
|
||||
v.sig_html = None
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, msg="Your sig has been updated.")
|
||||
return render_template("settings_profile.html", v=v, msg="Your sig has been updated.")
|
||||
|
||||
elif request.values.get("friends") == "":
|
||||
v.friends = None
|
||||
v.friends_html = None
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, msg="Your friends list has been updated.")
|
||||
return render_template("settings_profile.html", v=v, msg="Your friends list has been updated.")
|
||||
|
||||
elif request.values.get("enemies") == "":
|
||||
v.enemies = None
|
||||
v.enemies_html = None
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, msg="Your enemies list has been updated.")
|
||||
return render_template("settings_profile.html", v=v, msg="Your enemies list has been updated.")
|
||||
|
||||
elif (v.patron or v.id == MOOSE_ID) and request.values.get("sig"):
|
||||
sig = request.values.get("sig")[:200]
|
||||
|
@ -178,9 +168,7 @@ def settings_profile_post(v):
|
|||
return {"error": reason}, 401
|
||||
|
||||
if len(sig_html) > 1000:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error="Your sig is too long")
|
||||
|
||||
|
@ -188,9 +176,7 @@ def settings_profile_post(v):
|
|||
v.sig_html=sig_html
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
msg="Your sig has been updated.")
|
||||
|
||||
|
@ -213,9 +199,7 @@ def settings_profile_post(v):
|
|||
return {"error": reason}, 401
|
||||
|
||||
if len(friends_html) > 2000:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error="Your friends list is too long")
|
||||
|
||||
|
@ -231,9 +215,7 @@ def settings_profile_post(v):
|
|||
v.friends_html=friends_html
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
msg="Your friends list has been updated.")
|
||||
|
||||
|
@ -254,9 +236,7 @@ def settings_profile_post(v):
|
|||
return {"error": reason}, 401
|
||||
|
||||
if len(enemies_html) > 2000:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error="Your enemies list is too long")
|
||||
|
||||
|
@ -272,9 +252,7 @@ def settings_profile_post(v):
|
|||
v.enemies_html=enemies_html
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
msg="Your enemies list has been updated.")
|
||||
|
||||
|
@ -301,17 +279,13 @@ def settings_profile_post(v):
|
|||
bio += f"\n\n{url}"
|
||||
else:
|
||||
if request.headers.get("Authorization"): return {"error": "Image/Video files only"}, 400
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, error="Image/Video files only."), 400
|
||||
return render_template("settings_profile.html", v=v, error="Image/Video files only."), 400
|
||||
|
||||
bio_html = sanitize(bio)
|
||||
bans = filter_comment_html(bio_html)
|
||||
|
||||
if len(bio_html) > 10000:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error="Your bio is too long")
|
||||
|
||||
|
@ -329,7 +303,7 @@ def settings_profile_post(v):
|
|||
v.bio_html=bio_html
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
msg="Your bio has been updated.")
|
||||
|
||||
|
@ -428,16 +402,12 @@ def filters(v):
|
|||
filters=request.values.get("filters")[:1000].strip()
|
||||
|
||||
if filters == v.custom_filter_list:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_filters.html", v=v, error="You didn't change anything")
|
||||
return render_template("settings_filters.html", v=v, error="You didn't change anything")
|
||||
|
||||
v.custom_filter_list=filters
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_filters.html", v=v, msg="Your custom filters have been updated.")
|
||||
return render_template("settings_filters.html", v=v, msg="Your custom filters have been updated.")
|
||||
|
||||
@app.post("/changelogsub")
|
||||
@auth_required
|
||||
|
@ -455,12 +425,10 @@ def changelogsub(v):
|
|||
@limiter.limit("1/second")
|
||||
@auth_required
|
||||
def namecolor(v):
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
|
||||
color = str(request.values.get("color", "")).strip()
|
||||
if color.startswith('#'): color = color[1:]
|
||||
if len(color) != 6: return render_template(f"{template}settings_security.html", v=v, error="Invalid color code")
|
||||
if len(color) != 6: return render_template("settings_security.html", v=v, error="Invalid color code")
|
||||
v.namecolor = color
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
@ -470,12 +438,10 @@ def namecolor(v):
|
|||
@limiter.limit("1/second")
|
||||
@auth_required
|
||||
def themecolor(v):
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
|
||||
themecolor = str(request.values.get("themecolor", "")).strip()
|
||||
if themecolor.startswith('#'): themecolor = themecolor[1:]
|
||||
if len(themecolor) != 6: return render_template(f"{template}settings_security.html", v=v, error="Invalid color code")
|
||||
if len(themecolor) != 6: return render_template("settings_security.html", v=v, error="Invalid color code")
|
||||
v.themecolor = themecolor
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
@ -537,12 +503,10 @@ def gumroad(v):
|
|||
@limiter.limit("1/second")
|
||||
@auth_required
|
||||
def titlecolor(v):
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
|
||||
titlecolor = str(request.values.get("titlecolor", "")).strip()
|
||||
if titlecolor.startswith('#'): titlecolor = titlecolor[1:]
|
||||
if len(titlecolor) != 6: return render_template(f"{template}settings_profile.html", v=v, error="Invalid color code")
|
||||
if len(titlecolor) != 6: return render_template("settings_profile.html", v=v, error="Invalid color code")
|
||||
v.titlecolor = titlecolor
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
@ -552,12 +516,9 @@ def titlecolor(v):
|
|||
@limiter.limit("1/second")
|
||||
@auth_required
|
||||
def verifiedcolor(v):
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
|
||||
verifiedcolor = str(request.values.get("verifiedcolor", "")).strip()
|
||||
if verifiedcolor.startswith('#'): verifiedcolor = verifiedcolor[1:]
|
||||
if len(verifiedcolor) != 6: return render_template(f"{template}settings_profile.html", v=v, error="Invalid color code")
|
||||
if len(verifiedcolor) != 6: return render_template("settings_profile.html", v=v, error="Invalid color code")
|
||||
v.verifiedcolor = verifiedcolor
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
@ -654,9 +615,7 @@ def settings_log_out_others(v):
|
|||
submitted_password = request.values.get("password", "").strip()
|
||||
|
||||
if not v.verifyPass(submitted_password):
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_security.html", v=v, error="Incorrect Password"), 401
|
||||
return render_template("settings_security.html", v=v, error="Incorrect Password"), 401
|
||||
|
||||
v.login_nonce += 1
|
||||
|
||||
|
@ -666,9 +625,7 @@ def settings_log_out_others(v):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_security.html", v=v, msg="All other devices have been logged out")
|
||||
return render_template("settings_security.html", v=v, msg="All other devices have been logged out")
|
||||
|
||||
|
||||
@app.post("/settings/images/profile")
|
||||
|
@ -703,9 +660,7 @@ def settings_images_profile(v):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, msg="Profile picture successfully updated.")
|
||||
return render_template("settings_profile.html", v=v, msg="Profile picture successfully updated.")
|
||||
|
||||
|
||||
@app.post("/settings/images/banner")
|
||||
|
@ -730,9 +685,7 @@ def settings_images_banner(v):
|
|||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, msg="Banner successfully updated.")
|
||||
return render_template("settings_profile.html", v=v, msg="Banner successfully updated.")
|
||||
|
||||
|
||||
@app.post("/settings/delete/profile")
|
||||
|
@ -745,9 +698,7 @@ def settings_delete_profile(v):
|
|||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v,
|
||||
return render_template("settings_profile.html", v=v,
|
||||
msg="Profile picture successfully removed.")
|
||||
|
||||
@app.post("/settings/delete/banner")
|
||||
|
@ -760,26 +711,20 @@ def settings_delete_banner(v):
|
|||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, msg="Banner successfully removed.")
|
||||
return render_template("settings_profile.html", v=v, msg="Banner successfully removed.")
|
||||
|
||||
|
||||
@app.get("/settings/blocks")
|
||||
@auth_required
|
||||
def settings_blockedpage(v):
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_blocks.html", v=v)
|
||||
return render_template("settings_blocks.html", v=v)
|
||||
|
||||
@app.get("/settings/css")
|
||||
@auth_required
|
||||
def settings_css_get(v):
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_css.html", v=v)
|
||||
return render_template("settings_css.html", v=v)
|
||||
|
||||
@app.post("/settings/css")
|
||||
@limiter.limit("1/second")
|
||||
|
@ -792,18 +737,14 @@ def settings_css(v):
|
|||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_css.html", v=v)
|
||||
return render_template("settings_css.html", v=v)
|
||||
|
||||
@app.get("/settings/profilecss")
|
||||
@auth_required
|
||||
def settings_profilecss_get(v):
|
||||
|
||||
if v.truecoins < 1000 and not v.patron and v.admin_level == 0 : return f"You must have +1000 {COINS_NAME} or be a paypig to set profile css."
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profilecss.html", v=v)
|
||||
return render_template("settings_profilecss.html", v=v)
|
||||
|
||||
@app.post("/settings/profilecss")
|
||||
@limiter.limit("1/second")
|
||||
|
@ -815,9 +756,7 @@ def settings_profilecss(v):
|
|||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profilecss.html", v=v)
|
||||
return render_template("settings_profilecss.html", v=v)
|
||||
|
||||
@app.post("/settings/block")
|
||||
@limiter.limit("1/second")
|
||||
|
@ -879,9 +818,7 @@ def settings_unblock_user(v):
|
|||
@auth_required
|
||||
def settings_apps(v):
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_apps.html", v=v)
|
||||
return render_template("settings_apps.html", v=v)
|
||||
|
||||
|
||||
@app.post("/settings/remove_discord")
|
||||
|
@ -902,9 +839,7 @@ def settings_remove_discord(v):
|
|||
@auth_required
|
||||
def settings_content_get(v):
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_filters.html", v=v)
|
||||
return render_template("settings_filters.html", v=v)
|
||||
|
||||
@app.post("/settings/name_change")
|
||||
@limiter.limit("1/second")
|
||||
|
@ -914,16 +849,12 @@ def settings_name_change(v):
|
|||
new_name=request.values.get("name").strip()
|
||||
|
||||
if new_name==v.username:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error="You didn't change anything")
|
||||
|
||||
if not re.match(valid_username_regex, new_name):
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error="This isn't a valid username.")
|
||||
|
||||
|
@ -937,9 +868,7 @@ def settings_name_change(v):
|
|||
).one_or_none()
|
||||
|
||||
if x and x.id != v.id:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error=f"Username `{new_name}` is already in use.")
|
||||
|
||||
|
@ -975,9 +904,7 @@ def settings_song_change(v):
|
|||
elif song.startswith("https://youtu.be/"):
|
||||
id = song.split("https://youtu.be/")[1]
|
||||
else:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, error="Not a youtube link.")
|
||||
return render_template("settings_profile.html", v=v, error="Not a youtube link.")
|
||||
|
||||
if "?" in id: id = id.split("?")[0]
|
||||
if "&" in id: id = id.split("&")[0]
|
||||
|
@ -992,21 +919,15 @@ def settings_song_change(v):
|
|||
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json()
|
||||
duration = req['items'][0]['contentDetails']['duration']
|
||||
if duration == 'P0D':
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, error="Can't use a live youtube video!")
|
||||
return render_template("settings_profile.html", v=v, error="Can't use a live youtube video!")
|
||||
|
||||
if "H" in duration:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, error="Duration of the video must not exceed 10 minutes.")
|
||||
return render_template("settings_profile.html", v=v, error="Duration of the video must not exceed 10 minutes.")
|
||||
|
||||
if "M" in duration:
|
||||
duration = int(duration.split("PT")[1].split("M")[0])
|
||||
if duration > 10:
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html", v=v, error="Duration of the video must not exceed 10 minutes.")
|
||||
return render_template("settings_profile.html", v=v, error="Duration of the video must not exceed 10 minutes.")
|
||||
|
||||
|
||||
if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User.id).filter_by(song=v.song).count() == 1:
|
||||
|
@ -1026,9 +947,7 @@ def settings_song_change(v):
|
|||
try: ydl.download([f"https://youtube.com/watch?v={id}"])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}settings_profile.html",
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error="Age-restricted videos aren't allowed.")
|
||||
|
||||
|
@ -1048,14 +967,12 @@ def settings_song_change(v):
|
|||
@limiter.limit("1/second")
|
||||
@auth_required
|
||||
def settings_title_change(v):
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
|
||||
if v.flairchanged: abort(403)
|
||||
|
||||
new_name=request.values.get("title").strip()[:100].replace("𒐪","")
|
||||
|
||||
if new_name==v.customtitle: return render_template(f"{template}settings_profile.html", v=v, error="You didn't change anything")
|
||||
if new_name==v.customtitle: return render_template("settings_profile.html", v=v, error="You didn't change anything")
|
||||
|
||||
v.customtitleplain = new_name
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue