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

master
Aevann1 2021-12-13 23:57:53 +02:00
commit 6a970e2a39
13 changed files with 32 additions and 33 deletions

View File

@ -32,7 +32,6 @@ class Submission(Base):
views = Column(Integer, default=0)
deleted_utc = Column(Integer, default=0)
distinguish_level = Column(Integer, default=0)
created_str = Column(String)
stickied = Column(String)
is_pinned = Column(Boolean, default=False)
private = Column(Boolean, default=False)
@ -60,14 +59,6 @@ class Submission(Base):
awards = relationship("AwardRelationship", viewonly=True)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs:
kwargs["created_utc"] = int(time.time())
kwargs["created_str"] = time.strftime(
"%I:%M %p on %d %b %Y", time.gmtime(
kwargs["created_utc"]))
super().__init__(*args, **kwargs)
def __repr__(self):

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,9 @@ def auth_desired(f):
def wrapper(*args, **kwargs):
v = get_logged_in_user()
if request.host == 'old.rdrama.net' and not (v and v.admin_level): abort(403)
check_ban_evade(v)
resp = make_response(f(*args, v=v, **kwargs))
@ -63,6 +66,8 @@ def auth_required(f):
if not v: abort(401)
if request.host == 'old.rdrama.net' and not v.admin_level: abort(403)
check_ban_evade(v)
g.v = v
@ -82,6 +87,8 @@ def is_not_banned(f):
if not v: abort(401)
if request.host == 'old.rdrama.net' and not v.admin_level: abort(403)
check_ban_evade(v)
if v.is_suspended: return {"error": "You can't perform this action while being banned."}, 403

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)

View File

@ -558,4 +558,4 @@
.comment.collapsed .invisible-on-collapse {
visibility: hidden;
}
</style>
</style>

View File

@ -81,4 +81,4 @@
{% endif %}
</ul>
</div>
</div>
</div>

View File

@ -37,4 +37,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -396,4 +396,4 @@
background: -webkit-linear-gradient(left, red, orange, yellow, green, blue, indigo, violet );
text-shadow:-1px -1px 0 black,1px -1px 0 black,-1px 1px 0 black,1px 1px 0 black;
}
</style>
</style>

View File

@ -560,7 +560,6 @@ CREATE TABLE public.submissions (
is_banned boolean,
over_18 boolean,
distinguish_level integer,
created_str character varying(255),
deleted_utc integer NOT NULL,
domain_ref integer,
is_approved integer NOT NULL,