MCPcopy Create free account
hub / github.com/Roy3838/Observer / _sessions

Function _sessions

api/remote.py:526–541  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

524
525
526async 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
544async def _charge_turn(user: AuthenticatedUser, turn_id: str) -> bool:

Callers 2

remote_listenFunction · 0.85
remote_sendFunction · 0.85

Calls 3

get_current_userFunction · 0.90
_require_ownerFunction · 0.85
_require_codeFunction · 0.85

Tested by

no test coverage detected