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:
@@ -11,7 +11,10 @@ import uuid6
|
||||
|
||||
from hotpocket_backend.apps.accounts.models import AccessToken
|
||||
from hotpocket_backend.apps.core.conf import settings
|
||||
from hotpocket_soa.dto.accounts import AccessTokensQuery
|
||||
from hotpocket_soa.dto.accounts import (
|
||||
AccessTokenMetaUpdateIn,
|
||||
AccessTokensQuery,
|
||||
)
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -54,6 +57,16 @@ class AccessTokensService:
|
||||
f'Access Token not found: pk=`{pk}`',
|
||||
) from exception
|
||||
|
||||
def get_by_key(self, *, key: str) -> AccessToken:
|
||||
try:
|
||||
query_set = AccessToken.active_objects
|
||||
|
||||
return query_set.get(key=key)
|
||||
except AccessToken.DoesNotExist as exception:
|
||||
raise self.AccessTokenNotFound(
|
||||
f'Access Token not found: key=`{key}`',
|
||||
) from exception
|
||||
|
||||
def search(self,
|
||||
*,
|
||||
query: AccessTokensQuery,
|
||||
@@ -79,3 +92,27 @@ class AccessTokensService:
|
||||
access_token.soft_delete()
|
||||
|
||||
return True
|
||||
|
||||
def update_meta(self,
|
||||
*,
|
||||
pk: uuid.UUID,
|
||||
update: AccessTokenMetaUpdateIn,
|
||||
) -> AccessToken:
|
||||
access_token = AccessToken.active_objects.get(pk=pk)
|
||||
|
||||
next_meta = {
|
||||
**(access_token.meta or {}),
|
||||
}
|
||||
|
||||
if update.version is not None:
|
||||
next_meta['version'] = update.version
|
||||
|
||||
if update.platform is not None:
|
||||
next_meta['platform'] = update.platform
|
||||
|
||||
access_token.meta = next_meta
|
||||
access_token.save()
|
||||
|
||||
access_token.refresh_from_db()
|
||||
|
||||
return access_token
|
||||
|
||||
Reference in New Issue
Block a user