def _ser_attempt(a: SendAttempt) -> dict: return { "id": a.id, "campaign_id": a.campaign_id, "campaign_recipient_id": a.campaign_recipient_id, "account_id": a.gmail_account_id, "attempt_number": a.attempt_number, "outcome": a.outcome, "error_class": a.error_class, "error_message": (a.error_message or "")[:300], "message_id": a.message_id, "provider_response": (a.provider_response or "")[:300], "created_at": a.created_at.isoformat() if a.created_at else None, } @router.get("/list") === test_send out === 125: return {"ok": False, "error": "No OAuth token stored for this account", 137: return {"ok": False, "stage": "temp_failed", "detail": str(e)[:400], 144: return {"ok": True, "stage": "accepted", "detail": "Gmail accepted the message", 154: return {"ok": False, "stage": "perm_failed", "detail": err[:400], 177: return {"accounts": [{"id": a.id, "email": a.email, 186: return {"templates": [{"id": t.id, "name": t.name} for t in rows]} return {"ok": True, "stage": "accepted", "detail": "Gmail accepted the message", "message_id": result.get("message_id"), "thread_id": result.get("thread_id"), 137: return {"ok": False, "stage": "temp_failed", "detail": str(e)[:400], 143: {"to": str(payload.to_email), "message_id": result.get("message_id")}) 144: return {"ok": True, "stage": "accepted", "detail": "Gmail accepted the message", 145: "message_id": result.get("message_id"), 148: "provider_response": _clip(str(result.get("raw_response", ""))), 154: return {"ok": False, "stage": "perm_failed", "detail": err[:400], 157: "provider_response": _clip(str(result.get("raw_response", ""))),