Disconnect logic a bit

This commit is contained in:
Jeremy Zhang 2018-11-04 19:03:42 +00:00
parent 1ef44e1290
commit ca834b758f

View File

@ -47,7 +47,7 @@ class Gateway(Namespace):
def on_disconnect(self): def on_disconnect(self):
if "user_keys" not in session: if "user_keys" not in session:
return disconnect()
if "socket_guild_id" not in session: if "socket_guild_id" not in session:
disconnect() disconnect()
else: else:
@ -75,6 +75,8 @@ class Gateway(Namespace):
self.teardown_db_session() self.teardown_db_session()
def on_heartbeat(self, data): def on_heartbeat(self, data):
if "socket_guild_id" not in session:
disconnect()
guild_id = data["guild_id"] guild_id = data["guild_id"]
visitor_mode = data["visitor_mode"] visitor_mode = data["visitor_mode"]
if not visitor_mode: if not visitor_mode:
@ -99,6 +101,8 @@ class Gateway(Namespace):
self.teardown_db_session() self.teardown_db_session()
def on_channel_list(self, data): def on_channel_list(self, data):
if "socket_guild_id" not in session:
disconnect()
guild_id = data["guild_id"] guild_id = data["guild_id"]
visitor_mode = data["visitor_mode"] visitor_mode = data["visitor_mode"]
channels = None channels = None
@ -116,6 +120,8 @@ class Gateway(Namespace):
self.teardown_db_session() self.teardown_db_session()
def on_current_user_info(self, data): def on_current_user_info(self, data):
if "socket_guild_id" not in session:
disconnect()
guild_id = data["guild_id"] guild_id = data["guild_id"]
if "user_keys" in session and not session["unauthenticated"]: if "user_keys" in session and not session["unauthenticated"]:
dbMember = get_guild_member(guild_id, session["user_id"]) dbMember = get_guild_member(guild_id, session["user_id"])
@ -158,6 +164,8 @@ class Gateway(Namespace):
return color return color
def on_lookup_user_info(self, data): def on_lookup_user_info(self, data):
if "socket_guild_id" not in session:
disconnect()
guild_id = data["guild_id"] guild_id = data["guild_id"]
name = data["name"] name = data["name"]
discriminator = data["discriminator"] discriminator = data["discriminator"]