BTHLABS-61: Service layer refactoring

A journey to fix `ValidationError` in Pocket imports turned service
layer refactoring :D
This commit is contained in:
2025-10-12 18:37:32 +00:00
parent ac7a8dd90e
commit 8b86145519
45 changed files with 1023 additions and 337 deletions

View File

@@ -7,6 +7,7 @@ from bthlabs_jsonrpc_core import register_method
from django import db
from django.http import HttpRequest
from hotpocket_backend.apps.core.rpc import wrap_soa_errors
from hotpocket_soa.services import (
AccessTokensService,
AccountsService,
@@ -17,6 +18,7 @@ LOGGER = logging.getLogger(__name__)
@register_method('accounts.access_tokens.create', namespace='accounts')
@wrap_soa_errors
def create(request: HttpRequest,
auth_key: str,
meta: dict,
@@ -27,7 +29,7 @@ def create(request: HttpRequest,
account_uuid=None,
key=auth_key,
)
except AuthKeysService.AuthKeyNotFound as exception:
except AuthKeysService.NotFound as exception:
LOGGER.error(
'Unable to issue access token: %s',
exception,
@@ -37,7 +39,7 @@ def create(request: HttpRequest,
try:
account = AccountsService().get(pk=auth_key_object.account_uuid)
except AccountsService.AccountNotFound as exception:
except AccountsService.NotFound as exception:
LOGGER.error(
'Unable to issue access token: %s',
exception,

View File

@@ -44,7 +44,7 @@ def check_access_token(request: HttpRequest,
access_token=access_token_object,
update=meta_update,
)
except AccessTokensService.AccessTokenNotFound as exception:
except AccessTokensService.NotFound as exception:
LOGGER.error(
'Access Token not found: account_uuid=`%s` key=`%s`',
request.user.pk,
@@ -52,7 +52,7 @@ def check_access_token(request: HttpRequest,
exc_info=exception,
)
result = False
except AccessTokensService.AccessTokenAccessDenied as exception:
except AccessTokensService.AccessDenied as exception:
LOGGER.error(
'Access Token access denied: account_uuid=`%s` key=`%s`',
request.user.pk,