useEmail.ts

deepspace-crm · crm, email-handles, deepspace-mail, react-hook, identity-management, email

useEmail — DeepSpace email integration for the CRM. The user's @app.space identity is owned by the deepspace-mail app: it writes to the `email_handles` collection in `workspace:default`. Any other app (us) can read that collection by registering it as a shared scope in `_app.ts

/**
 * useEmail — DeepSpace email integration for the CRM.
 *
 * The user's @app.space identity is owned by the deepspace-mail app: it
 * writes to the `email_handles` collection in `workspace:default`. Any
 * other app (us) can read that collection by registering it as a shared
 * scope in `_app.tsx`. We never write here — claiming a handle is
 * exclusively done in deepspace-mail (mail.app.space).
 *
 * Flow:
 *   - has handle → emailAddress is the @app.space address; sendEmail uses
 *     it as the FROM via the `email/send` integration on the api-worker.
 *   - no handle → hasEmail is false; the email tab and the compose dialog
 *     prompt the user to set one up at https://deepspace-mail.app.space.
 *
 * Caveat: inbound from external providers (e.g. hotmail → a@app.space)
 * is curren

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key