# Generated by Django 5.2.8 on 2025-12-06 15:03

import apps.sigils.fields
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("chats", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="EmailCollector",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "name",
                    models.CharField(
                        blank=True,
                        help_text="Optional label to identify this collector.",
                        max_length=255,
                    ),
                ),
                ("subject", models.CharField(blank=True, max_length=255)),
                ("sender", models.CharField(blank=True, max_length=255)),
                ("body", models.CharField(blank=True, max_length=255)),
                (
                    "fragment",
                    models.CharField(
                        blank=True,
                        help_text="Pattern with [sigils] to extract values from the body.",
                        max_length=255,
                    ),
                ),
                (
                    "use_regular_expressions",
                    models.BooleanField(
                        default=False,
                        help_text="Treat subject, sender and body filters as regular expressions (case-insensitive).",
                    ),
                ),
            ],
            options={
                "verbose_name": "Email Collector",
                "verbose_name_plural": "Email Collectors",
                "db_table": "core_emailcollector",
            },
        ),
        migrations.CreateModel(
            name="EmailOutbox",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "host",
                    apps.sigils.fields.SigilShortAutoField(
                        help_text="Gmail: smtp.gmail.com. GoDaddy: smtpout.secureserver.net",
                        max_length=100,
                    ),
                ),
                (
                    "port",
                    models.PositiveIntegerField(
                        default=587,
                        help_text="Gmail: 587 (TLS). GoDaddy: 587 (TLS) or 465 (SSL)",
                    ),
                ),
                (
                    "username",
                    apps.sigils.fields.SigilShortAutoField(
                        blank=True,
                        help_text="Full email address for Gmail or GoDaddy",
                        max_length=100,
                    ),
                ),
                (
                    "password",
                    apps.sigils.fields.SigilShortAutoField(
                        blank=True,
                        help_text="Email account password or app password",
                        max_length=100,
                    ),
                ),
                (
                    "use_tls",
                    models.BooleanField(
                        default=True, help_text="Check for Gmail or GoDaddy on port 587"
                    ),
                ),
                (
                    "use_ssl",
                    models.BooleanField(
                        default=False,
                        help_text="Check for GoDaddy on port 465; Gmail does not use SSL",
                    ),
                ),
                (
                    "from_email",
                    apps.sigils.fields.SigilShortAutoField(
                        blank=True,
                        help_text="Default From address; usually the same as username",
                        max_length=254,
                        verbose_name="From Email",
                    ),
                ),
                (
                    "is_enabled",
                    models.BooleanField(
                        default=True,
                        help_text="Disable to remove this outbox from automatic selection.",
                    ),
                ),
                (
                    "priority",
                    models.IntegerField(
                        default=0,
                        help_text="Higher values are selected first when multiple outboxes are available.",
                    ),
                ),
            ],
            options={
                "verbose_name": "Email Outbox",
                "verbose_name_plural": "Email Outboxes",
                "db_table": "nodes_emailoutbox",
                "ordering": ["-priority", "id"],
            },
        ),
        migrations.CreateModel(
            name="EmailInbox",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "username",
                    apps.sigils.fields.SigilShortAutoField(
                        help_text="Login name for the mailbox", max_length=255
                    ),
                ),
                (
                    "host",
                    apps.sigils.fields.SigilShortAutoField(
                        help_text="Examples: Gmail IMAP 'imap.gmail.com', Gmail POP3 'pop.gmail.com', GoDaddy IMAP 'imap.secureserver.net', GoDaddy POP3 'pop.secureserver.net'",
                        max_length=255,
                    ),
                ),
                (
                    "port",
                    models.PositiveIntegerField(
                        default=993,
                        help_text="Common ports: Gmail IMAP 993, Gmail POP3 995, GoDaddy IMAP 993, GoDaddy POP3 995",
                    ),
                ),
                ("password", apps.sigils.fields.SigilShortAutoField(max_length=255)),
                (
                    "protocol",
                    apps.sigils.fields.SigilShortAutoField(
                        choices=[("imap", "IMAP"), ("pop3", "POP3")],
                        default="imap",
                        help_text="IMAP keeps emails on the server for access across devices; POP3 downloads messages to a single device and may remove them from the server",
                        max_length=5,
                    ),
                ),
                ("use_ssl", models.BooleanField(default=True)),
                (
                    "is_enabled",
                    models.BooleanField(
                        default=True,
                        help_text="Disable to remove this inbox from automatic selection.",
                    ),
                ),
                (
                    "priority",
                    models.IntegerField(
                        default=0,
                        help_text="Higher values are selected first when multiple inboxes are available.",
                    ),
                ),
                (
                    "avatar",
                    models.ForeignKey(
                        blank=True,
                        help_text="Avatar that owns this profile when not linked directly to a user or group.",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="chats.chatavatar",
                    ),
                ),
            ],
            options={
                "verbose_name": "Email Inbox",
                "verbose_name_plural": "Email Inboxes",
                "db_table": "core_emailinbox",
                "ordering": ["-priority", "id"],
            },
        ),
    ]
