Repository navigation
Per-domain hooks: who may hold an address, and a stored-mail notification - #6
Merged
Merged
Conversation
…tion A domain can add api/domain-hooks/<domain>.js with two optional hooks, documented in api/domain-hooks/_template.js: - verifyUsername decides whether a user may claim a new address. It fails closed: no explicit yes, no address. - onEmailStored is told about each message once every recipient of it is stored, so it cannot hold mail up. Domains without a hook file behave as before. Adds the masky.ai hooks, which hand both decisions to the Masky API. The address index and mail profile are written by the API only; the rules file and sendEmail now reflect that. A subject is kept to one header line. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Usernames may contain a dot, but the address index is keyed by username and a Realtime Database key cannot hold one, so setting up first.last failed. The index key now stores a dot as a comma; names without a dot keep their key, so existing entries are unchanged. - A username cannot start or end with a dot or have two in a row. - Only a well-formed username is looked up in the index. - Delivery between two addresses on a domain no longer depends on the capitalisation of the recipient. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One VCMail Lambda can serve several mail domains. This lets each domain add its own rules in a file named after it,
api/domain-hooks/<domain>.js. Two optional hooks, both documented inapi/domain-hooks/_template.js:verifyUsernamedecides whether a user may claim a new address. It runs insetupEmailbefore anything is written, and is skipped when the caller already holds the address. It fails closed: if the hook throws, takes longer than 12 seconds, or returns anything other than{ allowed: true }, the address is refused.onEmailStoredis told about each message after it is stored, withsource: 'ses'for mail from outside and'local'for mail between two addresses on the domain. It runs once every recipient of a message is stored, so it cannot hold mail up. Errors are logged and ignored, and it is cut off after 5 seconds.A domain without a hook file behaves exactly as before.
masky.ai
api/domain-hooks/masky.ai.jshands both decisions to the Masky API by invoking its Lambda directly, so the rules for masky.ai addresses live in one place. The role needslambda:InvokeFunctionon that function.Also
database.rules.jsonandsendEmailnow reflect that. This supersedes Username index: holder-only writes #5.sendEmailkeeps the subject to one header line.storeEmailForUserreturns what it stored.npm testruns both test files.Testing
npm test), 32 of them new: the hook runner (allow, refuse, throw, hang, load failure, non-answers), the masky.ai hook,setupEmailwith and without a hook,sendEmail, and the order of storing and notifying for a message with several recipients.Deploying
The Lambda bundle must include
api/domainHooks.jsand theapi/domain-hooks/directory.🤖 Generated with Claude Code