feat: Gmail OAuth flow, per-user SMTP, message dedup, account disable toggle
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/b77800ca-b452-4427-b0bf-63403e906916
This commit is contained in:
@@ -446,6 +446,38 @@ class AuditLog(Base):
|
||||
)
|
||||
|
||||
|
||||
class UserSmtpConfig(Base):
|
||||
"""Per-user SMTP relay configuration for email forwarding fallback."""
|
||||
|
||||
__tablename__ = "user_smtp_configs"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
user_id = Column(
|
||||
Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False, unique=True
|
||||
)
|
||||
|
||||
host = Column(String(255), nullable=False, default="smtp.gmail.com")
|
||||
port = Column(Integer, nullable=False, default=587)
|
||||
username = Column(String(255), nullable=False, default="")
|
||||
encrypted_password = Column(Text, nullable=False, default="")
|
||||
use_tls = Column(Boolean, default=True)
|
||||
|
||||
created_at = Column(
|
||||
DateTime(timezone=True),
|
||||
default=lambda: datetime.now(timezone.utc),
|
||||
nullable=False,
|
||||
)
|
||||
updated_at = Column(
|
||||
DateTime(timezone=True),
|
||||
default=lambda: datetime.now(timezone.utc),
|
||||
onupdate=lambda: datetime.now(timezone.utc),
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", backref="smtp_config")
|
||||
|
||||
|
||||
class DownloadedMessageId(Base):
|
||||
"""
|
||||
Tracks unique message IDs that have already been downloaded and forwarded.
|
||||
|
||||
@@ -339,3 +339,35 @@ class ProviderPreset(BaseModel):
|
||||
|
||||
class ProviderListResponse(BaseModel):
|
||||
providers: List[ProviderPreset]
|
||||
|
||||
|
||||
# User SMTP Config Schemas
|
||||
class UserSmtpConfigBase(BaseModel):
|
||||
host: str = "smtp.gmail.com"
|
||||
port: int = Field(587, gt=0, lt=65536)
|
||||
username: str = ""
|
||||
use_tls: bool = True
|
||||
|
||||
|
||||
class UserSmtpConfigUpdate(UserSmtpConfigBase):
|
||||
password: Optional[str] = None # Only provided when changing the password
|
||||
|
||||
|
||||
class UserSmtpConfigResponse(UserSmtpConfigBase):
|
||||
id: int
|
||||
user_id: int
|
||||
has_password: bool # True if a password is stored (value is never returned)
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
# Gmail OAuth Schemas
|
||||
class GmailAuthorizeResponse(BaseModel):
|
||||
authorization_url: str
|
||||
|
||||
|
||||
class GmailCallbackRequest(BaseModel):
|
||||
code: str
|
||||
redirect_uri: str
|
||||
|
||||
Reference in New Issue
Block a user