fix(chat): scope chatStore in stream+messages session guards
The session existence checks in GET /stream and POST /messages were using options?.chatStore (global DB), so secondary-project sessions would throw notFound before the scoped ChatManager ran. Replaces with resolveScopedChatStore.
This commit is contained in:
@@ -478,10 +478,7 @@ export function registerChatRoutes(ctx: ApiRoutesContext, deps: ChatRouteDeps):
|
||||
*/
|
||||
router.get("/chat/sessions/:id/stream", rateLimit(RATE_LIMITS.sse), async (req, res) => {
|
||||
try {
|
||||
const chatStore = options?.chatStore;
|
||||
if (!chatStore) {
|
||||
throw internalError("Chat store not available");
|
||||
}
|
||||
const { chatStore } = await resolveScopedChatStore(req.query.projectId as string | undefined);
|
||||
const chatManager = await resolveScopedChatManager(req.query.projectId as string | undefined);
|
||||
|
||||
const sessionId = String(req.params.id);
|
||||
@@ -567,10 +564,7 @@ export function registerChatRoutes(ctx: ApiRoutesContext, deps: ChatRouteDeps):
|
||||
*/
|
||||
router.post("/chat/sessions/:id/messages", rateLimit(RATE_LIMITS.sse), async (req, res) => {
|
||||
try {
|
||||
const chatStore = options?.chatStore;
|
||||
if (!chatStore) {
|
||||
throw internalError("Chat store not available");
|
||||
}
|
||||
const { chatStore } = await resolveScopedChatStore(req.query.projectId as string | undefined);
|
||||
|
||||
const { content, modelProvider, modelId, attachments } = req.body as {
|
||||
content?: string;
|
||||
|
||||
Reference in New Issue
Block a user