You've already forked hotpocket
BTHLABS-50: Safari Web Extension: Reloaded
Turns out, getting this thing out into the wild isn't as simple as I thought :D Co-authored-by: Tomek Wójcik <labs@tomekwojcik.pl> Co-committed-by: Tomek Wójcik <labs@tomekwojcik.pl>
This commit is contained in:
@@ -36,3 +36,8 @@ class AccessTokenOut(ModelOut):
|
||||
class AccessTokensQuery(Query):
|
||||
account_uuid: uuid.UUID
|
||||
before: uuid.UUID | None = pydantic.Field(default=None)
|
||||
|
||||
|
||||
class AccessTokenMetaUpdateIn(pydantic.BaseModel):
|
||||
version: str | None = None
|
||||
platform: str | None = None
|
||||
|
||||
@@ -6,7 +6,11 @@ import uuid
|
||||
from hotpocket_backend.apps.accounts.services import (
|
||||
AccessTokensService as BackendAccessTokensService,
|
||||
)
|
||||
from hotpocket_soa.dto.accounts import AccessTokenOut, AccessTokensQuery
|
||||
from hotpocket_soa.dto.accounts import (
|
||||
AccessTokenMetaUpdateIn,
|
||||
AccessTokenOut,
|
||||
AccessTokensQuery,
|
||||
)
|
||||
|
||||
from .base import ProxyService, SOAError
|
||||
|
||||
@@ -76,6 +80,33 @@ class AccessTokensService(ProxyService):
|
||||
else:
|
||||
raise
|
||||
|
||||
def get_by_key(self,
|
||||
*,
|
||||
account_uuid: uuid.UUID,
|
||||
key: str,
|
||||
) -> AccessTokenOut:
|
||||
try:
|
||||
result = AccessTokenOut.model_validate(
|
||||
self.call(
|
||||
self.backend_access_tokens_service,
|
||||
'get_by_key',
|
||||
key=key,
|
||||
),
|
||||
from_attributes=True,
|
||||
)
|
||||
|
||||
if result.account_uuid != account_uuid:
|
||||
raise self.AccessTokenAccessDenied(
|
||||
f'account_uuid=`{account_uuid}` key=`{key}`',
|
||||
)
|
||||
|
||||
return result
|
||||
except SOAError as exception:
|
||||
if isinstance(exception.__cause__, BackendAccessTokensService.AccessTokenNotFound) is True:
|
||||
raise self.AccessTokenNotFound(f'account_uuid=`{account_uuid}` pk=`{key}`') from exception
|
||||
else:
|
||||
raise
|
||||
|
||||
def search(self,
|
||||
*,
|
||||
query: AccessTokensQuery,
|
||||
@@ -98,3 +129,18 @@ class AccessTokensService(ProxyService):
|
||||
'delete',
|
||||
pk=access_token.pk,
|
||||
)
|
||||
|
||||
def update_meta(self,
|
||||
*,
|
||||
access_token: AccessTokenOut,
|
||||
update: AccessTokenMetaUpdateIn,
|
||||
) -> AccessTokenOut:
|
||||
return AccessTokenOut.model_validate(
|
||||
self.call(
|
||||
self.backend_access_tokens_service,
|
||||
'update_meta',
|
||||
pk=access_token.pk,
|
||||
update=update,
|
||||
),
|
||||
from_attributes=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user