forked from rDrama/rDrama
dfsfds
parent
3134f3860e
commit
1279734995
|
@ -439,13 +439,8 @@ def badge_grant_post(v):
|
|||
if url: new_badge.url = url
|
||||
|
||||
g.db.add(new_badge)
|
||||
g.db.flush()
|
||||
|
||||
text = f"""
|
||||
@{v.username} has given you the following profile badge:
|
||||
\n\n![]({new_badge.path})
|
||||
\n\n{new_badge.name}
|
||||
"""
|
||||
text = f"@{v.username} has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}"
|
||||
send_notification(user.id, text)
|
||||
|
||||
g.db.commit()
|
||||
|
|
|
@ -121,9 +121,6 @@ def buy(v, award):
|
|||
g.db.add(v)
|
||||
|
||||
|
||||
|
||||
g.db.flush()
|
||||
|
||||
if award == "lootbox":
|
||||
send_repeatable_notification(995, f"@{v.username} bought a lootbox!")
|
||||
for i in [1,2,3,4,5]:
|
||||
|
|
|
@ -406,9 +406,6 @@ def api_comment(v):
|
|||
g.db.add(c_jannied)
|
||||
g.db.flush()
|
||||
|
||||
|
||||
|
||||
|
||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||
g.db.add(n)
|
||||
|
||||
|
@ -446,8 +443,6 @@ def api_comment(v):
|
|||
|
||||
g.db.flush()
|
||||
|
||||
|
||||
|
||||
n = Notification(comment_id=c2.id, user_id=v.id)
|
||||
g.db.add(n)
|
||||
|
||||
|
@ -476,9 +471,6 @@ def api_comment(v):
|
|||
|
||||
g.db.add(c2)
|
||||
g.db.flush()
|
||||
|
||||
|
||||
|
||||
n = Notification(comment_id=c2.id, user_id=v.id)
|
||||
g.db.add(n)
|
||||
|
||||
|
@ -501,13 +493,6 @@ def api_comment(v):
|
|||
)
|
||||
|
||||
g.db.add(c3)
|
||||
g.db.flush()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
body = "zozzle"
|
||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||
|
@ -529,13 +514,6 @@ def api_comment(v):
|
|||
zozbot.coins += 3
|
||||
g.db.add(zozbot)
|
||||
|
||||
g.db.flush()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -562,7 +540,6 @@ def api_comment(v):
|
|||
for x in notify_users:
|
||||
n = Notification(comment_id=c.id, user_id=x)
|
||||
g.db.add(n)
|
||||
g.db.flush()
|
||||
|
||||
if parent.author.id != v.id:
|
||||
try:
|
||||
|
@ -822,8 +799,6 @@ def edit_comment(cid, v):
|
|||
|
||||
g.db.add(c)
|
||||
|
||||
g.db.flush()
|
||||
|
||||
notify_users = NOTIFY_USERS(body_html, v.id)
|
||||
soup = BeautifulSoup(body_html, features="html.parser")
|
||||
mentions = soup.find_all("a", href=re.compile("^/@(\w+)"))
|
||||
|
@ -838,6 +813,9 @@ def edit_comment(cid, v):
|
|||
if v.any_block_exists(user): continue
|
||||
if user.id != v.id: notify_users.add(user.id)
|
||||
|
||||
|
||||
g.db.flush()
|
||||
|
||||
for x in notify_users:
|
||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).first()
|
||||
if not notif:
|
||||
|
|
|
@ -44,8 +44,7 @@ def check_for_alts(current_id):
|
|||
new_alt = Alt(user1=past_id, user2=current_id)
|
||||
g.db.add(new_alt)
|
||||
g.db.flush()
|
||||
except BaseException:
|
||||
pass
|
||||
except: pass
|
||||
|
||||
alts = g.db.query(Alt)
|
||||
otheralts = alts.filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
|
||||
|
|
|
@ -727,6 +727,8 @@ def submit_post(v):
|
|||
|
||||
url = request.values.get("url", "").strip()
|
||||
|
||||
thumburl = None
|
||||
|
||||
if v.agendaposter and not v.marseyawarded:
|
||||
for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l)
|
||||
title = title.replace('I ', f'@{v.username} ')
|
||||
|
@ -931,6 +933,28 @@ def submit_post(v):
|
|||
body = body.replace('I ', f'@{v.username} ')
|
||||
body = censor_slurs2(body).upper().replace(' ME ', f' @{v.username} ')
|
||||
|
||||
if request.files.get('file') and request.headers.get("cf-ipcountry") != "T1":
|
||||
file=request.files["file"]
|
||||
if file.content_type.startswith('image/'):
|
||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||
file.save(name)
|
||||
url = process_image(name)
|
||||
body = f"![]({url})\n\n{body}"
|
||||
|
||||
name2 = name.replace('.webp', 'r.webp')
|
||||
copyfile(name, name2)
|
||||
thumburl = process_image(name2, True)
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link']
|
||||
body += f"\n\n{url}"
|
||||
else:
|
||||
if request.headers.get("Authorization"): return {"error": f"Image/Video files only"}, 400
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}submit.html", v=v, error=f"Image/Video files only."), 400
|
||||
|
||||
if request.files.get("file2") and request.headers.get("cf-ipcountry") != "T1":
|
||||
file=request.files["file2"]
|
||||
if file.content_type.startswith('image/'):
|
||||
|
@ -988,7 +1012,8 @@ def submit_post(v):
|
|||
embed_url=embed,
|
||||
title=title[:500],
|
||||
title_html=title_html,
|
||||
created_utc=int(time.time())
|
||||
created_utc=int(time.time()),
|
||||
thumburl = thumburl
|
||||
)
|
||||
|
||||
g.db.add(new_post)
|
||||
|
@ -1020,37 +1045,6 @@ def submit_post(v):
|
|||
submission_id=new_post.id
|
||||
)
|
||||
g.db.add(vote)
|
||||
g.db.flush()
|
||||
|
||||
if request.files.get('file') and request.headers.get("cf-ipcountry") != "T1":
|
||||
|
||||
file = request.files['file']
|
||||
|
||||
if not file.content_type.startswith(('image/', 'video/')):
|
||||
if request.headers.get("Authorization"): return {"error": f"File type not allowed"}, 400
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}submit.html", v=v, error=f"File type not allowed.", title=title, body=request.values.get("body", "")), 400
|
||||
|
||||
if file.content_type.startswith('image/'):
|
||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||
file.save(name)
|
||||
new_post.url = process_image(name)
|
||||
|
||||
name2 = name.replace('.webp', 'r.webp')
|
||||
copyfile(name, name2)
|
||||
new_post.thumburl = process_image(name2, True)
|
||||
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
url = requests.request("POST", "https://api.imgur.com/3/upload", headers={'Authorization': f'Client-ID {CATBOX_KEY}'}, files=[('video', f)]).json()['data']['link']
|
||||
new_post.url = url
|
||||
|
||||
g.db.add(new_post)
|
||||
|
||||
g.db.flush()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1076,7 +1070,6 @@ def submit_post(v):
|
|||
add_notif(cid, user.id)
|
||||
|
||||
g.db.add(new_post)
|
||||
g.db.flush()
|
||||
|
||||
|
||||
if "rama" in request.host and "ivermectin" in new_post.body_html.lower():
|
||||
|
@ -1142,16 +1135,12 @@ def submit_post(v):
|
|||
g.db.add(c_jannied)
|
||||
g.db.flush()
|
||||
|
||||
|
||||
|
||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||
g.db.add(n)
|
||||
|
||||
if "rama" in request.host or "pcm" in request.host or new_post.url:
|
||||
new_post.comment_count = 1
|
||||
g.db.add(new_post)
|
||||
|
||||
if "rama" in request.host or "pcm" in request.host:
|
||||
if v.id == CARP_ID:
|
||||
if random.random() < 0.02: body = "i love you carp"
|
||||
else: body = ":#marseyfuckoffcarp:"
|
||||
|
@ -1160,7 +1149,6 @@ def submit_post(v):
|
|||
else: body = "wow, a good lawlzpost for once!"
|
||||
else: body = random.choice(snappyquotes)
|
||||
body += "\n\n"
|
||||
else: body = ""
|
||||
|
||||
if new_post.url:
|
||||
if new_post.url.startswith('https://old.reddit.com/r/'):
|
||||
|
@ -1208,12 +1196,11 @@ def submit_post(v):
|
|||
snappy.coins += 2
|
||||
g.db.add(snappy)
|
||||
|
||||
g.db.flush()
|
||||
|
||||
if not v.is_blocking(snappy):
|
||||
g.db.flush()
|
||||
n = Notification(comment_id=c.id, user_id=v.id)
|
||||
g.db.add(n)
|
||||
g.db.flush()
|
||||
|
||||
|
||||
v.post_count = g.db.query(Submission.id).filter_by(author_id=v.id, is_banned=False, deleted_utc=0).count()
|
||||
g.db.add(v)
|
||||
|
@ -1279,7 +1266,6 @@ def toggle_comment_nsfw(cid, v):
|
|||
if not comment.author_id == v.id and not v.admin_level > 1: abort(403)
|
||||
comment.over_18 = not comment.over_18
|
||||
g.db.add(comment)
|
||||
g.db.flush()
|
||||
|
||||
g.db.commit()
|
||||
|
||||
|
|
Loading…
Reference in New Issue