-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
41 lines (30 loc) · 1.18 KB
/
models.py
File metadata and controls
41 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Data models for Universal Mail Cleaner.
Contains dataclasses for IMAP account configuration and cleanup rules.
"""
from dataclasses import dataclass, asdict
@dataclass
class MailAccount:
"""Represents an IMAP or Gmail API account configuration."""
name: str # display name (e.g. "My GMX")
host: str # e.g. imap.gmx.net (unused for Gmail API accounts)
user: str # e.g. user@gmx.de
port: int = 993
trash_folder: str = "" # manual override, otherwise auto-detect
protocol: str = "IMAP" # "IMAP" or "Gmail API"
def to_dict(self): return asdict(self)
@classmethod
def from_dict(cls, d):
# Accept old config entries that lack the 'protocol' key
known = {k: v for k, v in d.items() if k in cls.__dataclass_fields__}
return cls(**known)
@dataclass
class CleanRule:
"""Defines a cleanup rule for automatic email deletion."""
name: str
target_account: str # account name or "All"
filter_type: str # older_than_days, subject, sender, size_mb
value: str
active: bool = True
def to_dict(self): return asdict(self)
@classmethod
def from_dict(cls, d): return cls(**d)