feat: per-user channel config for Google Chat and Nextcloud Talk
- New endpoints: POST /channels/google-chat/{username} and /webhook/nextcloud/{username}
- Channel secrets/config live in home/{username}/channels.json (gitignored)
- auth_utils: get_user_channels() helper reads channels.json
- Both routers load persona, audience/secret, backend, timeout per user;
set_context() wires the correct persona before building the system prompt
- Removed server-level channel settings from config.py and .env —
no user gets a channel until they create their own channels.json
- .gitignore: home/**/channels.json added
To migrate: update Google Chat Add-on webhook URL to /channels/google-chat/{username}
and re-register NC Talk bot at /webhook/nextcloud/{username}
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,3 +195,22 @@ def consume_invite(username: str) -> None:
|
||||
path.write_text(json.dumps(data) + "\n")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Per-user channel config
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _channels_path(username: str) -> Path:
|
||||
return settings.home_root() / username / "channels.json"
|
||||
|
||||
|
||||
def get_user_channels(username: str) -> dict:
|
||||
"""Return the parsed channels.json for a user, or {} if not found."""
|
||||
path = _channels_path(username)
|
||||
if not path.exists():
|
||||
return {}
|
||||
try:
|
||||
return json.loads(path.read_text())
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user