Skip to content
Snippets Groups Projects
Unverified Commit 0cbe4d0b authored by Timothy Carambat's avatar Timothy Carambat Committed by GitHub
Browse files

Make `userId` actually optional for workspaceThread endpoint (#2276)

parent 906eb70c
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,7 @@ const { WorkspaceThread } = require("../../../models/workspaceThread");
const { Workspace } = require("../../../models/workspace");
const { validApiKey } = require("../../../utils/middleware/validApiKey");
const { reqBody, multiUserMode } = require("../../../utils/http");
const {
streamChatWithWorkspace,
VALID_CHAT_MODE,
} = require("../../../utils/chats/stream");
const { VALID_CHAT_MODE } = require("../../../utils/chats/stream");
const { Telemetry } = require("../../../models/telemetry");
const { EventLogs } = require("../../../models/eventLogs");
const {
......@@ -71,7 +68,7 @@ function apiWorkspaceThreadEndpoints(app) {
*/
try {
const { slug } = request.params;
const { userId } = reqBody(request);
let { userId = null } = reqBody(request);
const workspace = await Workspace.get({ slug });
if (!workspace) {
......@@ -79,6 +76,11 @@ function apiWorkspaceThreadEndpoints(app) {
return;
}
// If the system is not multi-user and you pass in a userId
// it needs to be nullified as no users exist. This can still fail validation
// as we don't check if the userID is valid.
if (!response.locals.multiUserMode && !!userId) userId = null;
const { thread, message } = await WorkspaceThread.new(
workspace,
userId ? Number(userId) : null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment