{
  "id": "enum-emaildeliveryattemptstatus",
  "title": "Enum — EmailDeliveryAttemptStatus",
  "description": "Estados da tentativa de transporte de uma mensagem de e-mail.",
  "type": "enum-reference",
  "status": "implemented",
  "visibility": "public",
  "tags": [
    "sge/enums",
    "sge/email"
  ],
  "related": [
    "migration-07-email-delivery-attempts",
    "e-mails-notificacoes-e-entregas",
    "enum-emailmessagepurpose"
  ],
  "sourceRefs": [
    "https://github.com/sge-suite/sge/blob/master/app/Enums/EmailDeliveryAttemptStatus.php",
    "https://github.com/sge-suite/sge/blob/master/tests/Unit/Enums/EmailDeliveryAttemptStatusTest.php"
  ],
  "authors": [],
  "updated": null,
  "diagram": null,
  "body": "> [!success] Estado\n> A classe, o cast em `EmailDeliveryAttempt`, a migration, o Job de envio e os testes existem. O estado da tentativa não é o estado de leitura da notificação.\n\n## Contrato proposto\n\n| Case      | Valor persistido | Significado                                        |\n| --------- | ---------------- | -------------------------------------------------- |\n| `Queued`  | `queued`         | Tentativa criada e aguardando Job.                 |\n| `Sent`    | `sent`           | SMTP/provedor aceitou a mensagem.                  |\n| `Failed`  | `failed`         | Transporte falhou ou o Job não conseguiu concluir. |\n\nO fluxo é direto: `queued` passa para `sent` quando o SMTP/provedor aceita a mensagem, ou para `failed` quando ela falha. `notifications.read_at` continua sendo a fonte da leitura interna. Não usar `sending`, `read` ou `delivered` sem decisão explícita.\n\n## Checklist de implementação\n\n- [x] Criar `App\\Enums\\EmailDeliveryAttemptStatus` como enum string.\n- [x] Implementar rótulos e opções da interface.\n- [x] Adicionar cast em `EmailDeliveryAttempt`.\n- [x] Persistir os valores do enum em [email_delivery_attempts](doc:migration-07-email-delivery-attempts).\n- [x] Testar cases, valores, rótulos e opções.\n- [x] Testar as transições `queued → sent` e `queued → failed`, reprocessamento e criação de nova linha no reenvio.\n- [x] Salvar `sent` somente quando o transporte aceita o envio.\n\n## Relacionamentos\n\n- [E-mails, notificações e entregas](doc:e-mails-notificacoes-e-entregas)\n- [EmailMessagePurpose](doc:enum-emailmessagepurpose)\n- [Migration de email_delivery_attempts](doc:migration-07-email-delivery-attempts)",
  "sections": [
    {
      "id": "contrato-proposto",
      "level": 2,
      "title": "Contrato proposto",
      "text": "| Case      | Valor persistido | Significado                                        | | --------- | ---------------- | -------------------------------------------------- | | `Queued`  | `queued`         | Tentativa criada e aguardando Job.                 | | `Sent`    | `sent`           | SMTP/provedor aceitou a mensagem.                  | | `Failed`  | `failed`         | Transporte falhou ou o Job não conseguiu concluir. |  O fluxo é direto: `queued` passa para `sent` quando o SMTP/provedor aceita a mensagem, ou para `failed` quando ela falha. `notifications.read_at` continua sendo a fonte da leitura interna. Não usar `sending`, `read` ou `delivered` sem decisão explícita.",
      "line": 4
    },
    {
      "id": "checklist-de-implementacao",
      "level": 2,
      "title": "Checklist de implementação",
      "text": "- [x] Criar `App\\Enums\\EmailDeliveryAttemptStatus` como enum string. - [x] Implementar rótulos e opções da interface. - [x] Adicionar cast em `EmailDeliveryAttempt`. - [x] Persistir os valores do enum em [email_delivery_attempts](doc:migration-07-email-delivery-attempts). - [x] Testar cases, valores, rótulos e opções. - [x] Testar as transições `queued → sent` e `queued → failed`, reprocessamento e criação de nova linha no reenvio. - [x] Salvar `sent` somente quando o transporte aceita o envio.",
      "line": 14
    },
    {
      "id": "relacionamentos",
      "level": 2,
      "title": "Relacionamentos",
      "text": "- [E-mails, notificações e entregas](doc:e-mails-notificacoes-e-entregas) - [EmailMessagePurpose](doc:enum-emailmessagepurpose) - [Migration de email_delivery_attempts](doc:migration-07-email-delivery-attempts)",
      "line": 24
    }
  ],
  "sourcePath": "content/enum-emaildeliveryattemptstatus.md",
  "visuals": [],
  "apiVersion": 1
}
