Merge branch 'master' of https://github.com/Aevann1/Drama into snow

This commit is contained in:
Aevann1 2021-12-13 23:57:53 +02:00
commit 922f96afff
13 changed files with 32 additions and 33 deletions

View file

@ -987,7 +987,7 @@ def api_sticky_post(post_id, v):
@app.post("/ban_comment/<c_id>")
@limiter.limit("1/second")
@admin_level_required(1)
@admin_level_required(2)
@validate_formkey
def api_ban_comment(c_id, v):
@ -1012,7 +1012,7 @@ def api_ban_comment(c_id, v):
@app.post("/unban_comment/<c_id>")
@limiter.limit("1/second")
@admin_level_required(1)
@admin_level_required(2)
@validate_formkey
def api_unban_comment(c_id, v):

View file

@ -194,7 +194,7 @@ def api_comment(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url + process_image(name)
url = request.host_url[:-1] + process_image(name)
body += f"\n\n![]({url})"
@ -724,7 +724,7 @@ def edit_comment(cid, v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url + process_image(name)
url = request.host_url[:-1] + process_image(name)
body += f"\n\n![]({url})"
body_md = CustomRenderer().render(mistletoe.Document(body))

View file

@ -53,6 +53,7 @@ def publish(pid, v):
post = get_post(pid)
if not post.author_id == v.id: abort(403)
post.private = False
post.created_utc = int(time.time())
g.db.add(post)
notify_users = NOTIFY_USERS(f'{post.body_html}{post.title}', v.id)
@ -97,7 +98,7 @@ def post_id(pid, anything=None, v=None):
try: pid = int(pid)
except Exception as e: pass
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new'
if 'rdrama.net' in request.host and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new'
elif v: defaultsortingcomments = v.defaultsortingcomments
else: defaultsortingcomments = "top"
@ -424,7 +425,7 @@ def edit_post(pid, v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url + process_image(name)
url = request.host_url[:-1] + process_image(name)
body += f"\n\n![]({url})"
@ -918,7 +919,7 @@ def submit_post(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url + process_image(name)
url = request.host_url[:-1] + process_image(name)
body += f"\n\n![]({url})"
@ -958,7 +959,8 @@ def submit_post(v):
body_html=body_html,
embed_url=embed,
title=title[:500],
title_html=title_html
title_html=title_html,
created_utc=int(time.time())
)
g.db.add(new_post)
@ -1017,7 +1019,7 @@ def submit_post(v):
if file.content_type.startswith('image/'):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
new_post.url = request.host_url + process_image(name)
new_post.url = request.host_url[:-1] + process_image(name)
elif file.content_type.startswith('video/'):
file.save("video.mp4")

View file

@ -130,7 +130,7 @@ def settings_profile_post(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url + process_image(name)
url = request.host_url[:-1] + process_image(name)
bio += f"\n\n![]({url})"
@ -320,7 +320,7 @@ def settings_profile_post(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url + process_image(name)
url = request.host_url[:-1] + process_image(name)
bio += f"\n\n![]({url})"
@ -726,7 +726,7 @@ def settings_images_profile(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
highres = request.host_url + process_image(name)
highres = request.host_url[:-1] + process_image(name)
if not highres: abort(400)
@ -762,7 +762,7 @@ def settings_images_banner(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
bannerurl = request.host_url + process_image(name)
bannerurl = request.host_url[:-1] + process_image(name)
if bannerurl:
if v.bannerurl and '/images/' in v.bannerurl : os.remove('/images/' + v.bannerurl.split('/images/')[1])

View file

@ -209,13 +209,13 @@ def transfer_coins(v, username):
if not v.patron and not receiver.patron:
tax = math.ceil(amount*0.03)
tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first()
if request.host == 'rdrama.net': tax_receiver.coins += tax/3
if 'rdrama.net' in request.host: tax_receiver.coins += tax/3
else: tax_receiver.coins += tax
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(TAX_RECEIVER_ID, log_message)
g.db.add(tax_receiver)
if request.host == 'rdrama.net':
if 'rdrama.net' in request.host:
carp = g.db.query(User).filter_by(id=CARP_ID).first()
carp.coins += tax/3
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
@ -493,7 +493,7 @@ def redditor_moment_redirect(username):
@auth_required
def followers(username, v):
u = get_user(username, v=v)
# if request.host == 'rdrama.net' and u.id == 147: abort(404)
# if 'rdrama.net' in request.host and u.id == 147: abort(404)
ids = [x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=u.id).all()]
users = g.db.query(User).filter(User.id.in_(ids)).all()
return render_template("followers.html", v=v, u=u, users=users)
@ -502,7 +502,7 @@ def followers(username, v):
@auth_required
def following(username, v):
u = get_user(username, v=v)
# if request.host == 'rdrama.net' and u.id == 147: abort(404)
# if 'rdrama.net' in request.host and u.id == 147: abort(404)
ids = [x[0] for x in g.db.query(Follow.target_id).filter_by(user_id=u.id).all()]
users = g.db.query(User).filter(User.id.in_(ids)).all()
return render_template("following.html", v=v, u=u, users=users)
@ -510,7 +510,7 @@ def following(username, v):
@app.get("/views")
@auth_required
def visitors(v):
if request.host == 'rdrama.net' and v.admin_level < 1 and not v.patron: return render_template("errors/patron.html", v=v)
if 'rdrama.net' in request.host and v.admin_level < 1 and not v.patron: return render_template("errors/patron.html", v=v)
viewers=sorted(v.viewers, key = lambda x: x.last_view_utc, reverse=True)
return render_template("viewers.html", v=v, viewers=viewers)