refactor(core): the core's owner filters go through userscope, each held by a second account

Tokens, notifications, quota, debug sessions and the reset-link burn filtered
their owner inline. Ten of the fifteen filters had no test that noticed one
going missing; each now has a test where another account's rows must not
count, show or change.
This commit is contained in:
2026-10-19 23:36:01 +02:00
parent 531eb2eef1
commit ad6ccbac05
11 changed files with 164 additions and 15 deletions
+2 -1
View File
@@ -16,6 +16,7 @@ from sqlalchemy.dialects.postgresql import insert as pg_insert
from sqlalchemy.engine import CursorResult
from sqlalchemy.orm import Session
from app.userscope import owned_by
from app import logs, sysconfig
from app.db import SessionLocal
from app.models import ApiQuotaUsage, QuotaEvent
@@ -173,7 +174,7 @@ def actions_today(db: Session, user_id: int, action: str) -> int:
select(func.count())
.select_from(QuotaEvent)
.where(
QuotaEvent.user_id == user_id,
owned_by(QuotaEvent.user_id, user_id),
QuotaEvent.action == action,
QuotaEvent.created_at >= pacific_day_start_utc(),
)