From dbd943f2098a2a9f7945e334242dbabc93472e7f Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 16 Feb 2018 19:50:53 +0000 Subject: [PATCH] Pass if socket_guild_id not in session --- .../titanembeds/blueprints/gateway/gateway.py | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/webapp/titanembeds/blueprints/gateway/gateway.py b/webapp/titanembeds/blueprints/gateway/gateway.py index e49f54d..f38ad10 100644 --- a/webapp/titanembeds/blueprints/gateway/gateway.py +++ b/webapp/titanembeds/blueprints/gateway/gateway.py @@ -46,27 +46,30 @@ class Gateway(Namespace): def on_disconnect(self): if "user_keys" not in session: return - guild_id = session["socket_guild_id"] - msg = {} - if session["unauthenticated"]: - msg = {"unauthenticated": True, "username": session["username"], "discriminator": session["user_id"]} + if "socket_guild_id" not in session: + disconnect() else: - msg = {"unauthenticated": False, "id": str(session["user_id"])} - emit("embed_user_disconnect", msg, room="GUILD_"+guild_id) - if guild_webhooks_enabled(guild_id): # Delete webhooks - dbguild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first() - guild_webhooks = json.loads(dbguild.webhooks) - name = "[Titan] " - username = session["username"] - if len(username) > 19: - username = username[:19] + guild_id = session["socket_guild_id"] + msg = {} if session["unauthenticated"]: - name = name + username + "#" + str(session["user_id"]) + msg = {"unauthenticated": True, "username": session["username"], "discriminator": session["user_id"]} else: - name = name + username + "#" + str(session["discriminator"]) - for webhook in guild_webhooks: - if webhook["name"] == name: - discord_api.delete_webhook(webhook["id"], webhook["token"]) + msg = {"unauthenticated": False, "id": str(session["user_id"])} + emit("embed_user_disconnect", msg, room="GUILD_"+guild_id) + if guild_webhooks_enabled(guild_id): # Delete webhooks + dbguild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first() + guild_webhooks = json.loads(dbguild.webhooks) + name = "[Titan] " + username = session["username"] + if len(username) > 19: + username = username[:19] + if session["unauthenticated"]: + name = name + username + "#" + str(session["user_id"]) + else: + name = name + username + "#" + str(session["discriminator"]) + for webhook in guild_webhooks: + if webhook["name"] == name: + discord_api.delete_webhook(webhook["id"], webhook["token"]) self.teardown_db_session() def on_heartbeat(self, data):