The sessions a /listen or /send request names, each under its own channel's trust rule: the WhatsApp code must be the caller's (so a token is required only when one is given); the Telegram code is enough on its own. Returns them with the caller, if signed in.
(request: Request, whatsapp: str | None, telegram: str | None)
| 524 | |
| 525 | |
| 526 | async def _sessions(request: Request, whatsapp: str | None, telegram: str | None) -> tuple[dict[Channel, str], AuthenticatedUser | None]: |
| 527 | """ |
| 528 | The sessions a /listen or /send request names, each under its own channel's trust rule: |
| 529 | the WhatsApp code must be the caller's (so a token is required only when one is given); |
| 530 | the Telegram code is enough on its own. Returns them with the caller, if signed in. |
| 531 | """ |
| 532 | sessions: dict[Channel, str] = {} |
| 533 | user = None |
| 534 | if whatsapp: |
| 535 | user = await get_current_user(request) |
| 536 | sessions["whatsapp"] = await _require_owner(whatsapp, user.id) |
| 537 | if telegram: |
| 538 | sessions["telegram"] = _require_code(telegram) |
| 539 | if not sessions: |
| 540 | raise HTTPException(status_code=400, detail="Give a whatsapp and/or telegram code.") |
| 541 | return sessions, user |
| 542 | |
| 543 | |
| 544 | async def _charge_turn(user: AuthenticatedUser, turn_id: str) -> bool: |
no test coverage detected