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) => {
|
router.get("/chat/sessions/:id/stream", rateLimit(RATE_LIMITS.sse), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const chatStore = options?.chatStore;
|
const { chatStore } = await resolveScopedChatStore(req.query.projectId as string | undefined);
|
||||||
if (!chatStore) {
|
|
||||||
throw internalError("Chat store not available");
|
|
||||||
}
|
|
||||||
const chatManager = await resolveScopedChatManager(req.query.projectId as string | undefined);
|
const chatManager = await resolveScopedChatManager(req.query.projectId as string | undefined);
|
||||||
|
|
||||||
const sessionId = String(req.params.id);
|
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) => {
|
router.post("/chat/sessions/:id/messages", rateLimit(RATE_LIMITS.sse), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const chatStore = options?.chatStore;
|
const { chatStore } = await resolveScopedChatStore(req.query.projectId as string | undefined);
|
||||||
if (!chatStore) {
|
|
||||||
throw internalError("Chat store not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
const { content, modelProvider, modelId, attachments } = req.body as {
|
const { content, modelProvider, modelId, attachments } = req.body as {
|
||||||
content?: string;
|
content?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user