mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
c602a31856
The UI already prevents child (delegated/subagent) chats from being
pinned, but the `PATCH /api/experimental/chats/{chat}` endpoint did not
enforce this. A direct API call could pin a child chat.
- Add a `400 Bad Request` guard in `patchChat` when `pinOrder > 0` and
the chat has a `ParentChatID`
- Add `TestChatPinOrder/RejectsChildChat` test
> 🤖
15 lines
473 B
SQL
15 lines
473 B
SQL
-- Defensive: fix any existing violating rows before adding constraints.
|
|
UPDATE chats SET pin_order = 0
|
|
WHERE pin_order > 0 AND parent_chat_id IS NOT NULL;
|
|
|
|
UPDATE chats SET pin_order = 0
|
|
WHERE pin_order > 0 AND archived = true;
|
|
|
|
ALTER TABLE chats
|
|
ADD CONSTRAINT chats_pin_order_parent_check
|
|
CHECK (pin_order = 0 OR parent_chat_id IS NULL);
|
|
|
|
ALTER TABLE chats
|
|
ADD CONSTRAINT chats_pin_order_archived_check
|
|
CHECK (pin_order = 0 OR archived = false);
|