GizStack
View .mdOpen in ChatGPTOpen in Claude

gizweb:outbox

An app's sent mail: each message is a record with its state, and each day counts its messages under the app's daily limit (counters.giz). Failed and bounced sends count too.

gizlang
import * as Outbox from "gizweb:outbox";

Types

Mail

gizlang
type Mail = { @Key id: string; recipient: string; subject: string; body: string; day: i64; state: string; }

One message of DAY (days since 1970): pending until the provider answers, then sent, queued or failed.

  • id: string
  • recipient: string
  • subject: string
  • body: string
  • day: i64
  • state: string

Functions

install

gizlang
function install(d: Data.Db): bool throws Model.Rejection

Makes the outbox tables when they are not there.

Effects: fail, read, write, console, io.

admit

gizlang
function admit(d: Data.Db, mail: Mail, limit: i64): bool throws Model.Rejection

Records MAIL as pending when its day has sent fewer than LIMIT; a 429 otherwise.

Effects: fail, read, write, console, io.

settle

gizlang
function settle(d: Data.Db, id: string, state: string): bool throws Model.Rejection

Sets the STATE of message ID.

Effects: fail, read, write, console, io.