Add email channel via Mailgun for Ask Simba
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>
This commit is contained in:
@@ -167,6 +167,23 @@ class UserService {
|
||||
);
|
||||
if (!response.ok) throw new Error("Failed to unlink WhatsApp number");
|
||||
}
|
||||
|
||||
async adminToggleEmail(userId: string): Promise<AdminUserRecord> {
|
||||
const response = await this.fetchWithRefreshToken(
|
||||
`${this.baseUrl}/admin/users/${userId}/email`,
|
||||
{ method: "PUT" },
|
||||
);
|
||||
if (!response.ok) throw new Error("Failed to enable email");
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async adminDisableEmail(userId: string): Promise<void> {
|
||||
const response = await this.fetchWithRefreshToken(
|
||||
`${this.baseUrl}/admin/users/${userId}/email`,
|
||||
{ method: "DELETE" },
|
||||
);
|
||||
if (!response.ok) throw new Error("Failed to disable email");
|
||||
}
|
||||
}
|
||||
|
||||
export interface AdminUserRecord {
|
||||
@@ -175,6 +192,8 @@ export interface AdminUserRecord {
|
||||
email: string;
|
||||
whatsapp_number: string | null;
|
||||
auth_provider: string;
|
||||
email_enabled: boolean;
|
||||
email_address: string | null;
|
||||
}
|
||||
|
||||
export { UserService };
|
||||
|
||||
Reference in New Issue
Block a user