| 264 | } |
| 265 | |
| 266 | func messageSummaryFromIdentity(m identity.Message) MessageSummaryView { |
| 267 | s := MessageSummaryView{ |
| 268 | ID: m.ID, |
| 269 | Direction: m.Direction, |
| 270 | From: m.Sender, |
| 271 | To: orEmptyStrings(m.ToRecipients), |
| 272 | CC: orEmptyStrings(m.CC), |
| 273 | ReplyTo: orEmptyStrings(m.ReplyTo), |
| 274 | Recipient: m.Recipient, |
| 275 | Subject: m.Subject, |
| 276 | ConversationID: m.ConversationID, |
| 277 | Status: m.InboxStatus, |
| 278 | SizeBytes: m.SizeBytes, |
| 279 | Labels: orEmptyStrings(m.Labels), |
| 280 | CreatedAt: m.CreatedAt.UTC().Format(time.RFC3339), |
| 281 | Auth: authVerdict(m.Auth), |
| 282 | Flagged: m.Flagged, |
| 283 | FlagReason: m.FlagReason, |
| 284 | } |
| 285 | if m.Direction == "outbound" { |
| 286 | s.HITLStatus = m.Status |
| 287 | s.WebhookStatus = m.WebhookStatus |
| 288 | s.WebhookError = m.WebhookError |
| 289 | // On outbound rows identity.Message.DeliveryStatus carries the |
| 290 | // delivery rollup (migration 031); inbound rows carry inbox_status, |
| 291 | // already surfaced as Status above. |
| 292 | s.DeliveryStatus = m.DeliveryStatus |
| 293 | s.DeliveryDetail = m.DeliveryDetail |
| 294 | s.SentAs = m.SentAs |
| 295 | } |
| 296 | return s |
| 297 | } |
| 298 | |
| 299 | // ListMessagesInput is the typed query surface for the message list. Cursor |
| 300 | // pagination (cursor/limit) replaces the legacy page_size/token (§4 |