diff --git a/files/helpers/discord.py b/files/helpers/discord.py index caa67bc4a1..695b635a88 100644 --- a/files/helpers/discord.py +++ b/files/helpers/discord.py @@ -57,4 +57,10 @@ def send_discord_message(message): headers = {"Authorization": f"Bot {BOT_TOKEN}"} data={"content": message} requests.post("https://discordapp.com/api/channels/924485611715452940/messages", headers=headers, data=data, timeout=5) - requests.post("https://discordapp.com/api/channels/924486091795484732/messages", headers=headers, data=data, timeout=5) \ No newline at end of file + requests.post("https://discordapp.com/api/channels/924486091795484732/messages", headers=headers, data=data, timeout=5) + + +def send_cringetopia_message(message): + headers = {"Authorization": f"Bot {BOT_TOKEN}"} + data={"content": message} + requests.post("https://discordapp.com/api/channels/965264044531527740/messages", headers=headers, data=data, timeout=5) \ No newline at end of file diff --git a/files/routes/posts.py b/files/routes/posts.py index e1fedc7f26..0db192a6b1 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -5,7 +5,7 @@ from files.helpers.wrappers import * from files.helpers.sanitize import * from files.helpers.filters import * from files.helpers.alerts import * -from files.helpers.discord import send_discord_message +from files.helpers.discord import send_discord_message, send_cringetopia_message from files.helpers.const import * from files.helpers.slots import * from files.classes import * @@ -88,16 +88,17 @@ def publish(pid, v): if post.club and not user.paid_dues: continue add_notif(cid, user.id) + g.db.commit() cache.delete_memoized(frontlist) cache.delete_memoized(User.userpagelisting) - if v.admin_level > 0 and ("[changelog]" in post.title.lower() or "(changelog)" in post.title.lower()): + if SITE == 'cringetopia.org': + send_cringetopia_message(post.permalink) + elif v.admin_level > 0 and ("[changelog]" in post.title.lower() or "(changelog)" in post.title.lower()): send_discord_message(post.permalink) cache.delete_memoized(changeloglist) - g.db.commit() - return redirect(post.permalink) @app.get("/submit") @@ -1375,12 +1376,6 @@ def submit_post(v, sub=None): 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) - cache.delete_memoized(frontlist) - cache.delete_memoized(User.userpagelisting) - if v.admin_level > 0 and ("[changelog]" in post.title.lower() or "(changelog)" in post.title.lower()) and not post.private: - send_discord_message(post.permalink) - cache.delete_memoized(changeloglist) - if v.id == PIZZASHILL_ID: for uid in PIZZA_VOTERS: autovote = Vote(user_id=uid, submission_id=post.id, vote_type=1) @@ -1393,6 +1388,15 @@ def submit_post(v, sub=None): g.db.commit() + cache.delete_memoized(frontlist) + cache.delete_memoized(User.userpagelisting) + + if SITE == 'cringetopia.org': + send_cringetopia_message(post.permalink) + elif v.admin_level > 0 and ("[changelog]" in post.title.lower() or "(changelog)" in post.title.lower()) and not post.private: + send_discord_message(post.permalink) + cache.delete_memoized(changeloglist) + if request.headers.get("Authorization"): return post.json else: post.voted = 1