def is_banned_from_room(self, room_id: str, user_id: str) -> (bool, Union[str, None]):
now = datetime.utcnow()
duration, time, username = self.env.cache.get_room_ban_timestamp(room_id, user_id)
if time is not None:
if time == "":
return False, None
time = datetime.fromtimestamp(float(time))
if now > time:
self.remove_room_ban(room_id, user_id)
return False, None
return True, str((time-now).seconds)
duration, time, username = self.get_room_ban_timestamp(room_id, user_id)
if time is None:
self.env.cache.set_room_ban_timestamp(room_id, user_id, "", "", "")
return False, None
if now > time:
self.remove_room_ban(room_id, user_id)
return False, None
self.env.cache.set_room_ban_timestamp(room_id, user_id, time.strftime(ConfigKeys.DEFAULT_DATE_FORMAT))
return True, str((time-now).seconds)
@with_session
After Change
def is_banned_from_room(self, room_id: str, user_id: str) -> (bool, Union[str, None]):
now = datetime.utcnow()
duration, time, username = self.env.cache.get_room_ban_timestamp(room_id, user_id)
if time is not None and len(time.strip()) != 0:
if time == "":
return False, None
time = datetime.fromtimestamp(float(time))