mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-19 12:40:09 +01:00
Make userId
actually optional for workspaceThread endpoint (#2276)
This commit is contained in:
parent
906eb70ca1
commit
0cbe4d0b04
@ -3,10 +3,7 @@ const { WorkspaceThread } = require("../../../models/workspaceThread");
|
|||||||
const { Workspace } = require("../../../models/workspace");
|
const { Workspace } = require("../../../models/workspace");
|
||||||
const { validApiKey } = require("../../../utils/middleware/validApiKey");
|
const { validApiKey } = require("../../../utils/middleware/validApiKey");
|
||||||
const { reqBody, multiUserMode } = require("../../../utils/http");
|
const { reqBody, multiUserMode } = require("../../../utils/http");
|
||||||
const {
|
const { VALID_CHAT_MODE } = require("../../../utils/chats/stream");
|
||||||
streamChatWithWorkspace,
|
|
||||||
VALID_CHAT_MODE,
|
|
||||||
} = require("../../../utils/chats/stream");
|
|
||||||
const { Telemetry } = require("../../../models/telemetry");
|
const { Telemetry } = require("../../../models/telemetry");
|
||||||
const { EventLogs } = require("../../../models/eventLogs");
|
const { EventLogs } = require("../../../models/eventLogs");
|
||||||
const {
|
const {
|
||||||
@ -71,7 +68,7 @@ function apiWorkspaceThreadEndpoints(app) {
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
const { slug } = request.params;
|
const { slug } = request.params;
|
||||||
const { userId } = reqBody(request);
|
let { userId = null } = reqBody(request);
|
||||||
const workspace = await Workspace.get({ slug });
|
const workspace = await Workspace.get({ slug });
|
||||||
|
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
@ -79,6 +76,11 @@ function apiWorkspaceThreadEndpoints(app) {
|
|||||||
return;
|
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(
|
const { thread, message } = await WorkspaceThread.new(
|
||||||
workspace,
|
workspace,
|
||||||
userId ? Number(userId) : null
|
userId ? Number(userId) : null
|
||||||
|
Loading…
Reference in New Issue
Block a user