feat(api,userbot,frontend): add accounts from the web ui and isolate per-account settings

This commit is contained in:
hh
2026-08-05 23:49:52 +02:00
parent 92fd20137e
commit 9c265af3d3
19 changed files with 917 additions and 268 deletions
@@ -0,0 +1,43 @@
"""per-account policy defaults
Revision ID: e7b4c2a9f861
Revises: d5f9b2c8e3a1
Create Date: 2026-08-05 23:10:00.000000
"""
from collections.abc import Sequence
from alembic import op
revision: str = "e7b4c2a9f861"
down_revision: str | None = "d5f9b2c8e3a1"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
_SCOPE_KEY = "capture_policy_account_id_scope_type_scope_id_key"
def upgrade() -> None:
op.execute("DROP INDEX ix_capture_policy_default")
op.execute(f"ALTER TABLE capture_policy DROP CONSTRAINT {_SCOPE_KEY}")
op.execute(
"CREATE UNIQUE INDEX ix_capture_policy_scope ON capture_policy "
"(account_id, scope_type, scope_id) NULLS NOT DISTINCT"
)
def downgrade() -> None:
op.execute(
"DELETE FROM capture_policy WHERE account_id IS NOT NULL "
"AND scope_type LIKE 'default_%'"
)
op.execute("DROP INDEX ix_capture_policy_scope")
op.execute(
f"ALTER TABLE capture_policy ADD CONSTRAINT {_SCOPE_KEY} "
"UNIQUE (account_id, scope_type, scope_id)"
)
op.execute(
"CREATE UNIQUE INDEX ix_capture_policy_default "
"ON capture_policy (scope_type) WHERE scope_type LIKE 'default_%'"
)