from notifications.plugins import CONFIRM_TOKEN_RESEND_SECONDS,CONFIRM_TOKEN_TTL_SECONDS def serialize_notification(row) -> dict: return { "id": str(row.id) if row.id else None, "kind": row.kind, "title": row.title, "body": row.body, "link_path": row.link_path, "inbox_id": row.inbox_id, "job_post_id": str(row.job_post_id) if row.job_post_id else None, "is_read": row.is_read, "created_at": row.created_at.isoformat() if row.created_at else None, } def serialize_confirmation_request(email: str,expires_at) -> dict: return { "email": email, "confirmation_sent": True, "expires_at": expires_at.isoformat() if expires_at else None, "expires_in": CONFIRM_TOKEN_TTL_SECONDS, "resend_after": CONFIRM_TOKEN_RESEND_SECONDS, } def serialize_confirmation_result(user,*,already_confirmed: bool = False) -> dict: """Deliberately narrow: this is an unauthenticated response, so no role or permissions.""" return { "email": user.email, "is_active": user.is_active, "is_approved": user.is_approved, "already_confirmed": already_confirmed, }