fix(talk): address remaining PR #741 reviewer feedback
Closes the seven outstanding items from the @claude review on PR #741: 1. Add empty `tests/client/talk/__init__.py` for pytest discovery parity with `tests/client/{collectives,news}/`. 2. Standardise boolean query params to integers — `includeStatus` was the string `"true"` in `list_conversations`/`list_participants` while every other flag (`noStatusUpdate`, `lookIntoFuture`, `setReadMarker`, `includeLastKnown`) used `1`/`0`. 3. Replace the `app:install || app:enable` chain in the spreed install hook with `app:install --keep-disabled --force || true; app:enable spreed`, so unrelated install failures surface as a clear "app not found" from `app:enable` rather than being silently masked. 4. Add `_validate_token()` (alphanumeric whitelist) and call it from all six TalkClient methods that interpolate the token into a URL path — defence-in-depth against pathological tokens reaching httpx. 5. Rename `TalkConversation.type` to `room_type` with `Field(alias="type")` and `populate_by_name=True`, so the field no longer shadows Python's builtin while preserving spreed's wire format on input. MCP responses now serialize `room_type` (field name) instead of `type`. 6. `mark_as_read` now passes `json=body or None` so the bodyless "mark everything as read" call doesn't send a spurious `{}` body and `Content-Type: application/json` header. 7. `_validate_message_text` rejects whitespace-only messages, not just empty strings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
9614c0b361
commit
f075540232
@@ -2,7 +2,7 @@
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
from .base import BaseResponse, StatusResponse
|
||||
|
||||
@@ -48,9 +48,25 @@ class TalkConversation(BaseModel):
|
||||
flows.
|
||||
"""
|
||||
|
||||
# ``populate_by_name=True`` lets us deserialize spreed's ``type`` key
|
||||
# into the ``room_type`` field while still allowing internal callers
|
||||
# to construct the model with ``room_type=...`` directly.
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
id: int
|
||||
token: str
|
||||
type: int
|
||||
# The spreed JSON wire format uses ``type`` for the room kind, but
|
||||
# ``type`` shadows Python's builtin within the class scope, which
|
||||
# would silently call this int field if anyone wrote ``type(...)``
|
||||
# in a validator or method on this model. Map to ``room_type`` and
|
||||
# alias the wire field instead.
|
||||
room_type: int = Field(
|
||||
alias="type",
|
||||
description=(
|
||||
"Conversation kind: 1=one-to-one, 2=group, 3=public, "
|
||||
"4=changelog, 5=former one-to-one, 6=note-to-self."
|
||||
),
|
||||
)
|
||||
name: str
|
||||
displayName: str
|
||||
description: str = ""
|
||||
|
||||
Reference in New Issue
Block a user