# Generated by Django 5.2.6 on 2025-09-24 09:21

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("codenerix_email", "0013_emailmessage_headers"),
    ]

    operations = [
        migrations.CreateModel(
            name="EmailReceived",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created"),
                ),
                (
                    "updated",
                    models.DateTimeField(auto_now=True, verbose_name="Updated"),
                ),
                ("imap_id", models.IntegerField(default=0, verbose_name="IMAP ID")),
                (
                    "eid",
                    models.CharField(
                        help_text="Unique Message-ID header",
                        max_length=512,
                        unique=True,
                        verbose_name="Message ID",
                    ),
                ),
                ("efrom", models.EmailField(max_length=254, verbose_name="From")),
                ("eto", models.EmailField(max_length=254, verbose_name="To")),
                ("subject", models.CharField(max_length=256, verbose_name="Subject")),
                (
                    "headers",
                    models.JSONField(blank=True, null=True, verbose_name="Headers"),
                ),
                ("body_text", models.TextField(blank=True, verbose_name="Body (Text)")),
                ("body_html", models.TextField(blank=True, verbose_name="Body (HTML)")),
                (
                    "date_received",
                    models.DateTimeField(
                        auto_now_add=True, verbose_name="Date received"
                    ),
                ),
                (
                    "bounce_type",
                    models.CharField(
                        blank=True,
                        choices=[("S", "Soft"), ("H", "Hard")],
                        default=None,
                        max_length=1,
                        null=True,
                        verbose_name="Bounce Type",
                    ),
                ),
                (
                    "bounce_reason",
                    models.CharField(
                        blank=True,
                        default=None,
                        max_length=512,
                        null=True,
                        verbose_name="Bounce Reason",
                    ),
                ),
                (
                    "email",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="receiveds",
                        to="codenerix_email.emailmessage",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "default_permissions": ("add", "change", "delete", "view", "list"),
            },
        ),
    ]
