"""Hosted mailboxes (SPEC Appendix D): every user's own mailbox on the Stalwart mail server beside the app. * :mod:`app.hosted.admin` — the mail server's management API (JMAP); * :mod:`app.hosted.provision` — idempotent setup: its database and role, the directory over the ``mail_directory`` view, the worker's sign-in; * :mod:`app.hosted.native` — the permanent account in the webmail, and how the worker signs in to it without any stored password; * :mod:`app.hosted.rawcache` — raw messages kept once, on the mail server: the webmail keeps only a bounded cache of them (§D.6 item 2). All of it is inert while ``HOSTED_MAILBOXES`` is off. """ from __future__ import annotations from app.config import get_settings # The webmail worker's sign-in on the mail server: ``user@domain%WORKER`` acts # for that user (Stalwart's master-user login, given the impersonate role only). WORKER_LOCALPART = "webmail-worker" def enabled() -> bool: return get_settings().hosted_mailboxes def worker_address() -> str: return f"{WORKER_LOCALPART}@{get_settings().app_domain}" def mail_hostname() -> str: settings = get_settings() return settings.mail_hostname or f"mail.{settings.app_domain}"