Mail relay: HTTP tests on a running Payload, account mail marked by recipient, panel wording, doctor rules tested
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
ea9703f8e3
commit
533f571d4d
@@ -7,8 +7,8 @@ import type { ResolvedRelayOptions } from './options.js'
|
||||
import { consumeRateLimit } from '../../shared/rateLimit.js'
|
||||
import { type RelayAnswer, type RelayRefusal, relayRequest } from './client.js'
|
||||
import { RELAY_DEFAULTS, type RelayStatusCode, relayStatusFor } from './constants.js'
|
||||
import { type MailKind, mailKindOf, takeMailContext } from './kinds.js'
|
||||
import { buildRelayMessage, type RelaySendRequest } from './message.js'
|
||||
import { currentMailKind, type MailKind, mailKindOf, takeExpectedMail } from './kinds.js'
|
||||
import { bareAddresses, buildRelayMessage, type RelaySendRequest } from './message.js'
|
||||
import { LOCAL_CODES, refreshRelayStatus, rotateRelayToken, type TokenUse, withRelayToken } from './session.js'
|
||||
import { readRelayStore, sha256Hex, updateRelayStore } from './store.js'
|
||||
|
||||
@@ -113,8 +113,11 @@ export type RelaySendContext = {
|
||||
* `retryable` or after no answer. An enrolment made on the way is not one of the three.
|
||||
*/
|
||||
export async function sendThroughRelay(payload: BasePayload, options: ResolvedRelayOptions, message: SendEmailOptions, context: RelaySendContext = {}): Promise<RelaySendResult> {
|
||||
const marked = takeMailContext()
|
||||
const kind = mailKindOf(message) ?? marked?.kind ?? options.kind?.(message) ?? 'system'
|
||||
// What the message is: its own mark; else what an auth operation said about a message to this address
|
||||
// (Payload's own account mail); else the surrounding runWithMailKind; else the project's rule; else unknown.
|
||||
const own = mailKindOf(message)
|
||||
const marked = own ? undefined : takeExpectedMail(bareAddresses((message as { to?: unknown }).to).addresses)
|
||||
const kind = own ?? marked?.kind ?? currentMailKind() ?? options.kind?.(message) ?? 'system'
|
||||
|
||||
const built = buildRelayMessage(message, { kind, replyTo: context.replyTo, senderName: context.senderName })
|
||||
if (!built.ok) {return failure('relay-error', 'client-invalid-message', built.problem)}
|
||||
|
||||
Reference in New Issue
Block a user