feat(nutrition): meals belong to the person who logged them
- meals.user_id (v1 databases gain it on open, DEFAULT '' keeps their meals the single user's); insert_meal, get_meals_between and delete_meal take the person, and delete only removes that person's meal. - turn_state.set_user / ToolContext.user_id carry the asker; logMeal, fetchMeals and deleteMeal use it. The v2 brain sets it for each reply. - Tests: two people never see or delete each other's meals, no user is v1's single user, and a v1 database opens with its meals kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,10 @@ broadcasting : Optional[bool]
|
||||
broadcast_action : Optional[str]
|
||||
A directive ("start"/"stop") recorded by the setBroadcast tool for the
|
||||
bridge to return to the bot, which owns the actual broadcast.
|
||||
user : Optional[str]
|
||||
v2: the Discord user ID of the person asking, set by the voice worker's
|
||||
brain. Tools that keep personal data (meals) store and read it under this
|
||||
person. None is v1's single user.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -29,6 +33,15 @@ def reset() -> None:
|
||||
"""Clear per-turn state. Call at the start of each request."""
|
||||
_state.broadcasting = None
|
||||
_state.broadcast_action = None
|
||||
_state.user = None
|
||||
|
||||
|
||||
def set_user(user_id: Optional[str]) -> None:
|
||||
_state.user = user_id
|
||||
|
||||
|
||||
def get_user() -> Optional[str]:
|
||||
return getattr(_state, "user", None)
|
||||
|
||||
|
||||
def set_broadcasting(value: Optional[bool]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user