mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 22:47:04 +01:00
Validate certain redis calls to make sure theyre ok
This commit is contained in:
parent
598661735a
commit
6df7bbab25
@ -39,6 +39,12 @@ class RedisQueue:
|
|||||||
else:
|
else:
|
||||||
return redis_store.get(key)
|
return redis_store.get(key)
|
||||||
|
|
||||||
|
def validate_not_none(self, key, data_key, data):
|
||||||
|
if data[data_key] == None:
|
||||||
|
redis_store.delete(key)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def get_channel_messages(self, guild_id, channel_id, after_snowflake=0):
|
def get_channel_messages(self, guild_id, channel_id, after_snowflake=0):
|
||||||
key = "/channels/{}/messages".format(channel_id)
|
key = "/channels/{}/messages".format(channel_id)
|
||||||
q = self.get(key, "get_channel_messages", {"channel_id": channel_id}, data_type="set")
|
q = self.get(key, "get_channel_messages", {"channel_id": channel_id}, data_type="set")
|
||||||
@ -92,6 +98,8 @@ class RedisQueue:
|
|||||||
def get_guild_member(self, guild_id, user_id):
|
def get_guild_member(self, guild_id, user_id):
|
||||||
key = "/guilds/{}/members/{}".format(guild_id, user_id)
|
key = "/guilds/{}/members/{}".format(guild_id, user_id)
|
||||||
q = self.get(key, "get_guild_member", {"guild_id": guild_id, "user_id": user_id})
|
q = self.get(key, "get_guild_member", {"guild_id": guild_id, "user_id": user_id})
|
||||||
|
if q and not self.validate_not_none(key, "username", q):
|
||||||
|
return self.get_user(user_id)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
def get_guild_member_named(self, guild_id, query):
|
def get_guild_member_named(self, guild_id, query):
|
||||||
@ -115,9 +123,13 @@ class RedisQueue:
|
|||||||
def get_guild(self, guild_id):
|
def get_guild(self, guild_id):
|
||||||
key = "/guilds/{}".format(guild_id)
|
key = "/guilds/{}".format(guild_id)
|
||||||
q = self.get(key, "get_guild", {"guild_id": guild_id})
|
q = self.get(key, "get_guild", {"guild_id": guild_id})
|
||||||
|
if q and not self.validate_not_none(key, "name", q):
|
||||||
|
return self.get_guild(guild_id)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
def get_user(self, user_id):
|
def get_user(self, user_id):
|
||||||
key = "/users/{}".format(user_id)
|
key = "/users/{}".format(user_id)
|
||||||
q = self.get(key, "get_user", {"user_id": user_id})
|
q = self.get(key, "get_user", {"user_id": user_id})
|
||||||
|
if q and not self.validate_not_none(key, "username", q):
|
||||||
|
return self.get_user(user_id)
|
||||||
return q
|
return q
|
Loading…
Reference in New Issue
Block a user