middleware session rollback / WATA pending payment
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from fastapi import APIRouter, Depends, HTTPException, Path, Query
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -84,3 +84,29 @@ async def read_all_notifications(
|
||||
):
|
||||
count = await wn_db.mark_all_read_for_identity(session, identity.id)
|
||||
return {"ok": True, "updated": count}
|
||||
|
||||
|
||||
@router.post("/notifications/{notification_id}/read", tags=["Notifications"])
|
||||
async def read_one_notification(
|
||||
notification_id: str = Path(..., min_length=1, max_length=64),
|
||||
session: AsyncSession = Depends(get_session),
|
||||
identity: Identity = Depends(verify_identity_token),
|
||||
):
|
||||
"""Пометить одно уведомление прочитанным. 404 если не найдено или не принадлежит юзеру."""
|
||||
ok = await wn_db.mark_one_read_for_identity(session, identity.id, notification_id)
|
||||
if not ok:
|
||||
raise HTTPException(status_code=404, detail="Уведомление не найдено")
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@router.delete("/notifications/{notification_id}", tags=["Notifications"])
|
||||
async def delete_one_notification(
|
||||
notification_id: str = Path(..., min_length=1, max_length=64),
|
||||
session: AsyncSession = Depends(get_session),
|
||||
identity: Identity = Depends(verify_identity_token),
|
||||
):
|
||||
"""Удалить одно уведомление. 404 если не найдено или не принадлежит юзеру."""
|
||||
ok = await wn_db.delete_one_for_identity(session, identity.id, notification_id)
|
||||
if not ok:
|
||||
raise HTTPException(status_code=404, detail="Уведомление не найдено")
|
||||
return {"ok": True}
|
||||
|
||||
Reference in New Issue
Block a user