domain/message.rs
1//! Customer and staff message delivery state.
2//!
3//! Message values distinguish drafts, approvals, queued sends, delivery evidence, and suppression
4//! reasons so automation can assist high-volume pet-parent communication without sending outside the
5//! configured channel, consent, and manager-review boundaries.
6
7use nutype::nutype;
8#[allow(unused_imports)]
9use serde::{Deserialize, Serialize};
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
12/// Direction of a message relative to the resort operation: inbound, outbound draft, queued, or sent.
13pub enum Direction {
14 /// Customer or staff message received by the resort and available as source context.
15 InboundReceived,
16 /// Outbound content exists only as a draft and must pass approval before queueing.
17 OutboundDraft,
18 /// Approved outbound message is queued for delivery through the configured channel.
19 OutboundQueued,
20 /// Outbound message was sent and should have delivery evidence recorded separately.
21 OutboundSent,
22}
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
25/// Message channel used for customer, staff, portal, phone-note, or internal communication.
26pub enum Channel {
27 /// Email channel, subject to email consent, address validation, and approval rules.
28 Email,
29 /// SMS channel, subject to texting consent, quiet-hour, and approval rules.
30 Sms,
31 /// Staff note from a call or voicemail, not an automated outbound send.
32 PhoneNote,
33 /// Customer portal channel controlled by portal delivery and consent settings.
34 Portal,
35 /// Internal staff communication that should not be treated as customer-facing delivery.
36 Internal,
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
40/// Normalized lifecycle states used to reconcile source-system data with domain workflows.
41pub enum Status {
42 /// Draft exists but has not yet requested approval or entered a send queue.
43 DraftCreated,
44 /// Draft is waiting for the required human or policy approval.
45 ApprovalRequested,
46 /// Approval was granted and the message may be queued through its channel.
47 ApprovedToQueue,
48 /// Message is queued for sending but has no delivery result yet.
49 Queued,
50 /// Delivery attempt was made and needs success/failure evidence.
51 SendAttempted,
52 /// Delivery evidence says the message reached the channel or provider.
53 Delivered,
54 /// Send failed and the message needs retry, suppression, or staff review before customer contact.
55 Failed,
56 /// Message was intentionally suppressed because consent, policy, duplicate, or review rules blocked sending.
57 Suppressed,
58 /// Message send was cancelled before delivery and must not be retried without a new approval path.
59 Cancelled,
60}
61
62#[nutype(
63 sanitize(trim),
64 validate(not_empty, len_char_max = 500),
65 derive(
66 Debug,
67 Clone,
68 PartialEq,
69 Eq,
70 PartialOrd,
71 Ord,
72 Hash,
73 Serialize,
74 Deserialize
75 )
76)]
77pub struct BodyRef(String);