Users can now receive a unique email address (ask+<token>@domain) and interact with Simba by sending emails. Inbound emails hit a Mailgun webhook, are authenticated via HMAC token lookup, processed through the LangChain agent, and replied to via the Mailgun API. - Extract shared SIMBA_SYSTEM_PROMPT to blueprints/conversation/prompts.py - Add email_enabled and email_hmac_token fields to User model - Create blueprints/email with webhook, signature validation, rate limiting - Add admin endpoints to enable/disable email per user - Update AdminPanel with Email column, toggle, and copy-address button - Add Mailgun env vars to .env.example - Include database migration for new fields Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 lines
609 B
Python
18 lines
609 B
Python
from tortoise import BaseDBAsyncClient
|
|
|
|
RUN_IN_TRANSACTION = True
|
|
|
|
|
|
async def upgrade(db: BaseDBAsyncClient) -> str:
|
|
return """
|
|
ALTER TABLE "users" ADD "email_enabled" BOOL NOT NULL DEFAULT FALSE;
|
|
ALTER TABLE "users" ADD "email_hmac_token" VARCHAR(16) UNIQUE;
|
|
CREATE INDEX "idx_users_email_h_a1b2c3" ON "users" ("email_hmac_token");"""
|
|
|
|
|
|
async def downgrade(db: BaseDBAsyncClient) -> str:
|
|
return """
|
|
DROP INDEX IF EXISTS "idx_users_email_h_a1b2c3";
|
|
ALTER TABLE "users" DROP COLUMN "email_hmac_token";
|
|
ALTER TABLE "users" DROP COLUMN "email_enabled";"""
|