mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-18 00:19:15 +00:00
refactor(tokens-repo): separate getting model dict
This commit is contained in:
parent
3cb7f29593
commit
b98ccb88d1
|
@ -87,12 +87,17 @@ class RedisTokensRepository(AbstractTokensRepository):
|
|||
if d[key] == "None":
|
||||
d[key] = None
|
||||
|
||||
def _token_from_hash(self, redis_key: str) -> Token:
|
||||
def _model_dict_from_hash(self, redis_key: str) -> Optional[dict]:
|
||||
r = self.connection
|
||||
if r.exists(redis_key):
|
||||
token_dict = r.hgetall(redis_key)
|
||||
RedisTokensRepository._prepare_model_dict(token_dict)
|
||||
return token_dict
|
||||
return None
|
||||
|
||||
def _token_from_hash(self, redis_key: str) -> Optional[Token]:
|
||||
token_dict = self._model_dict_from_hash(redis_key)
|
||||
if token_dict is not None:
|
||||
return Token(**token_dict)
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in a new issue