forked from retoor/devplacepy
feat: add audit logging for admin trash restore/purge and notification clear actions
- Record audit events in `admin_trash_restore` and `admin_trash_purge` endpoints with target metadata - Log `notification.read.all` event when user clears devRant notification feed - Include `devrant` as a valid origin in audit categories - Add `admin_section` and `pagination_query` fields to audit and backup schemas for UI consistency
This commit is contained in:
@@ -8,6 +8,7 @@ from devplacepy.services.devrant.params import merge_params
|
||||
from devplacepy.services.devrant.tokens import resolve_user
|
||||
from devplacepy.services.devrant.notifications import build_notif_feed, clear_notifications
|
||||
from devplacepy.routers.devrant._shared import dr_ok, unauthorized
|
||||
from devplacepy.services.audit import record as audit
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter()
|
||||
@@ -29,4 +30,11 @@ async def clear_notif_feed(request: Request):
|
||||
if not user:
|
||||
return unauthorized()
|
||||
clear_notifications(user)
|
||||
audit.record(
|
||||
request,
|
||||
"notification.read.all",
|
||||
user=user,
|
||||
origin="devrant",
|
||||
summary=f"{user['username']} cleared all notifications",
|
||||
)
|
||||
return dr_ok()
|
||||
|
||||
Reference in New Issue
Block a user