refactor(tokens-repo): use token repo in get_api_tokens_with_caller_flag

This commit is contained in:
Houkime 2022-12-23 12:29:32 +00:00
parent f928ca160a
commit e817de6228

View file

@ -4,12 +4,6 @@ from typing import Optional
from pydantic import BaseModel from pydantic import BaseModel
from mnemonic import Mnemonic from mnemonic import Mnemonic
from selfprivacy_api.utils.auth import (
get_tokens_info,
get_token_name,
)
from selfprivacy_api.repositories.tokens.json_tokens_repository import ( from selfprivacy_api.repositories.tokens.json_tokens_repository import (
JsonTokensRepository, JsonTokensRepository,
) )
@ -28,13 +22,13 @@ class TokenInfoWithIsCaller(BaseModel):
def get_api_tokens_with_caller_flag(caller_token: str) -> list[TokenInfoWithIsCaller]: def get_api_tokens_with_caller_flag(caller_token: str) -> list[TokenInfoWithIsCaller]:
"""Get the tokens info""" """Get the tokens info"""
caller_name = get_token_name(caller_token) caller_name = TOKEN_REPO.get_token_by_token_string(caller_token).device_name
tokens = get_tokens_info() tokens = TOKEN_REPO.get_tokens()
return [ return [
TokenInfoWithIsCaller( TokenInfoWithIsCaller(
name=token.name, name=token.device_name,
date=token.date, date=token.created_at,
is_caller=token.name == caller_name, is_caller=token.device_name == caller_name,
) )
for token in tokens for token in tokens
] ]