Патч
Some checks failed
Build And Push / publish (push) Has been cancelled

This commit is contained in:
2025-11-27 13:28:58 +03:00
parent 45a4123708
commit f3c9cb42d6
12 changed files with 172 additions and 88 deletions

View File

@ -4,6 +4,7 @@ from logging import getLogger
from typing import Annotated
from fastapi import APIRouter, Body, Depends, UploadFile, status
from orjson import loads
from apps.tdn.auth import token
from apps.users.auth import login
@ -387,22 +388,31 @@ async def delete_account(user: Annotated[User, Depends(login)]):
@router.get('/notifications')
async def notifications(user: Annotated[User, Depends(login)]):
keys = await cache.keys(f'tmk:{user.id}:*')
notif: list[dict[str, str | bool]] = []
for key in keys:
val = await cache.get(key)
if val is None:
continue
value = loads(val)
notif_val = value.copy()
notif.append(notif_val)
if value['is_read'] is False:
value['is_read'] = True
await cache.set(key, dumps(value))
return s.Notifications(
notifications=[
{
'id': 1,
'title': 'Заголовок уведомления 1',
'description': 'Описание уведомления',
},
{
'id': 2,
'title': 'Заголовок уведомления 2',
'description': 'Описание уведомления',
},
{
'id': 3,
'title': 'Заголовок уведомления 3',
'description': 'Описание уведомления',
},
]
notifications=notif,
)
@router.post('/complaint', status_code=status.HTTP_204_NO_CONTENT)
async def complaint(
user: Annotated[User, Depends(login)], complaints: s.Complaints
):
cache_key = f'complaint:{user.vita_id}'
await cache.set(cache_key, dumps(complaints.complaints))