Initial commit: webmail client (M0/M1)
Three-pane webmail client. - Backend: FastAPI + async SQLAlchemy + arq worker (Postgres/Redis), IMAP/SMTP sync, threading, search, drafts/outbox with undo, attachments, 2FA. - Frontend: React 18 + Vite + TypeScript + TanStack Query + Tailwind; three-pane UI with rich-text composer, light/dark themes, resizable panels. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
"""Dev-only: seed a demo user with a synced test mailbox so the UI has data.
|
||||
|
||||
Run from backend/ with the conda env active and services up:
|
||||
python scripts/seed_demo.py
|
||||
|
||||
Idempotent: reuses the demo user/account if they already exist and re-syncs.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.db import session_scope
|
||||
from app.identity.passwords import hash_password
|
||||
from app.models import Account, User
|
||||
from app.security.crypto import encrypt_secret
|
||||
from app.sync.engine import bootstrap_and_backfill
|
||||
|
||||
DEMO_LOCALPART = "demo"
|
||||
DEMO_PASSWORD = "webmailDemo1"
|
||||
MAILBOX_EMAIL = "test@imaginary-pixels.com"
|
||||
MAILBOX_PASSWORD = b"webmail!@A"
|
||||
HOST = "serwer2295308.home.pl"
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
from app.config import get_settings
|
||||
|
||||
domain = get_settings().app_domain
|
||||
handle = f"{DEMO_LOCALPART}@{domain}"
|
||||
|
||||
async with session_scope() as session:
|
||||
user = await session.scalar(select(User).where(User.handle == handle))
|
||||
if user is None:
|
||||
user = User(handle=handle, password_hash=hash_password(DEMO_PASSWORD))
|
||||
session.add(user)
|
||||
await session.flush()
|
||||
print(f"created user {handle}")
|
||||
else:
|
||||
# Reset password so the printed credentials always work.
|
||||
user.password_hash = hash_password(DEMO_PASSWORD)
|
||||
print(f"reusing user {handle}")
|
||||
|
||||
account = await session.scalar(
|
||||
select(Account).where(Account.user_id == user.id, Account.email == MAILBOX_EMAIL)
|
||||
)
|
||||
if account is None:
|
||||
account = Account(
|
||||
user_id=user.id,
|
||||
email=MAILBOX_EMAIL,
|
||||
display_name="Test Mailbox",
|
||||
color="#22aa77",
|
||||
imap_config={"host": HOST, "port": 993, "tls": "ssl", "auth": "password"},
|
||||
smtp_config={"host": HOST, "port": 465, "tls": "ssl", "auth": "password"},
|
||||
secret_ct=encrypt_secret(MAILBOX_PASSWORD),
|
||||
discovery_src="manual",
|
||||
state="backfilling",
|
||||
)
|
||||
session.add(account)
|
||||
await session.flush()
|
||||
print(f"created account {MAILBOX_EMAIL}")
|
||||
account_id = account.id
|
||||
|
||||
print("syncing mailbox (this hits the real IMAP server)…")
|
||||
count = await bootstrap_and_backfill(account_id)
|
||||
print(f"synced {count} messages")
|
||||
print("\n=== Log in at http://localhost:5173 ===")
|
||||
print(f" handle: {DEMO_LOCALPART}")
|
||||
print(f" password: {DEMO_PASSWORD}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user