thread Version updated

This commit is contained in:
2025-06-23 16:42:47 +05:30
parent 3ec45276f4
commit 20509c268a
8 changed files with 155 additions and 107 deletions

View File

@@ -14,12 +14,12 @@ export const threadCreate = async (
): Promise<void> => { ): Promise<void> => {
try { try {
const { userId, organization } = req.user || {}; const { userId, organization } = req.user || {};
const { projectId } = req.body; const { projectId, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) { if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" }); res.status(401).json({ message: "Unauthorized" });
return; return;
} }
if (!projectId || !organization || !userId) { if (!projectId || !organization || !userId || !versionId) {
res.status(400).json({ res.status(400).json({
message: "All fields are required", message: "All fields are required",
}); });
@@ -33,9 +33,9 @@ export const threadCreate = async (
message: "Project not found", message: "Project not found",
}); });
break; break;
case "CurrentVersion Data not found": case "Version Data not found":
res.status(404).json({ res.status(404).json({
message: "CurrentVersion Data not found", message: "Version Data not found",
}); });
break; break;
case "User not found": case "User not found":
@@ -67,12 +67,12 @@ export const threaddelete = async (
): Promise<void> => { ): Promise<void> => {
try { try {
const { userId, organization } = req.user || {}; const { userId, organization } = req.user || {};
const { projectId } = req.body; const { projectId, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) { if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" }); res.status(401).json({ message: "Unauthorized" });
return; return;
} }
if (!projectId || !organization || !userId) { if (!projectId || !organization || !userId || !versionId) {
res.status(400).json({ res.status(400).json({
message: "All fields are required", message: "All fields are required",
}); });
@@ -86,9 +86,9 @@ export const threaddelete = async (
message: "Project not found", message: "Project not found",
}); });
break; break;
case "CurrentVersion Data not found": case "Version Data not found":
res.status(404).json({ res.status(404).json({
message: "CurrentVersion Data not found", message: "Version Data not found",
}); });
break; break;
case "User not found": case "User not found":
@@ -119,12 +119,12 @@ export const threadUpdateTitle = async (
): Promise<void> => { ): Promise<void> => {
try { try {
const { userId, organization } = req.user || {}; const { userId, organization } = req.user || {};
const { projectId, threadId } = req.body; const { projectId, threadId, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) { if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" }); res.status(401).json({ message: "Unauthorized" });
return; return;
} }
if (!projectId || !threadId || !organization || !userId) { if (!projectId || !threadId || !organization || !userId || !versionId) {
res.status(400).json({ res.status(400).json({
message: "All fields are required", message: "All fields are required",
}); });
@@ -142,9 +142,9 @@ export const threadUpdateTitle = async (
message: "Project not found", message: "Project not found",
}); });
break; break;
case "CurrentVersion Data not found": case "Version Data not found":
res.status(404).json({ res.status(404).json({
message: "CurrentVersion Data not found", message: "Version Data not found",
}); });
break; break;
case "User not found": case "User not found":
@@ -176,12 +176,12 @@ export const threadComment = async (
): Promise<void> => { ): Promise<void> => {
try { try {
const { userId, organization } = req.user || {}; const { userId, organization } = req.user || {};
const { projectId, threadId } = req.body; const { projectId, threadId, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) { if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" }); res.status(401).json({ message: "Unauthorized" });
return; return;
} }
if (!projectId || !threadId || !organization || !userId) { if (!projectId || !threadId || !organization || !userId || !versionId) {
res.status(400).json({ res.status(400).json({
message: "All fields are required", message: "All fields are required",
}); });
@@ -196,9 +196,9 @@ export const threadComment = async (
message: "Project not found", message: "Project not found",
}); });
break; break;
case "CurrentVersion Data not found": case "Version Data not found":
res.status(404).json({ res.status(404).json({
message: "CurrentVersion Data not found", message: "Version Data not found",
}); });
break; break;
case "User not found": case "User not found":
@@ -236,12 +236,19 @@ export const threadCommentDelete = async (
): Promise<void> => { ): Promise<void> => {
try { try {
const { userId, organization } = req.user || {}; const { userId, organization } = req.user || {};
const { projectId, threadId, commentId } = req.body; const { projectId, threadId, commentId, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) { if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" }); res.status(401).json({ message: "Unauthorized" });
return; return;
} }
if (!projectId || !commentId || !threadId || !organization || !userId) { if (
!projectId ||
!commentId ||
!threadId ||
!organization ||
!userId ||
!versionId
) {
res.status(400).json({ res.status(400).json({
message: "All fields are required", message: "All fields are required",
}); });
@@ -255,9 +262,9 @@ export const threadCommentDelete = async (
message: "Project not found", message: "Project not found",
}); });
break; break;
case "CurrentVersion Data not found": case "Version Data not found":
res.status(404).json({ res.status(404).json({
message: "CurrentVersion Data not found", message: "Version Data not found",
}); });
break; break;
case "User not found": case "User not found":
@@ -298,18 +305,23 @@ export const getALLthreads = async (
): Promise<void> => { ): Promise<void> => {
try { try {
const { userId, organization } = req.user || {}; const { userId, organization } = req.user || {};
const { projectId } = req.params; const { projectId, versionId } = req.params;
if (!req.user?.userId || !req.user?.organization) { if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" }); res.status(401).json({ message: "Unauthorized" });
return; return;
} }
if (!projectId || !organization || !userId) { if (!projectId || !organization || !userId || !versionId) {
res.status(400).json({ res.status(400).json({
message: "All fields are required", message: "All fields are required",
}); });
return; return;
} }
const result = await findThreads({ projectId, userId, organization }); const result = await findThreads({
versionId,
projectId,
userId,
organization,
});
switch (result?.status) { switch (result?.status) {
case "Project not found": case "Project not found":
@@ -317,9 +329,9 @@ export const getALLthreads = async (
message: "Project not found", message: "Project not found",
}); });
break; break;
case "CurrentVersion Data not found": case "Version Data not found":
res.status(404).json({ res.status(404).json({
message: "CurrentVersion Data not found", message: "Version Data not found",
}); });
break; break;
case "User not found": case "User not found":

View File

@@ -1,35 +1,26 @@
import express from "express"; import express from "express";
import { tokenValidator } from "../../../shared/utils/token.ts"; import { tokenValidator } from "../../../shared/utils/token.ts";
import { getALLthreads, threadComment, threadCommentDelete, threadCreate, threaddelete, threadUpdateTitle } from "../v1Controllers/threadController/threadController.ts"; import {
getALLthreads,
threadComment,
threadCommentDelete,
threadCreate,
threaddelete,
threadUpdateTitle,
} from "../v1Controllers/threadController/threadController.ts";
const V1ThreadRoutes = express.Router(); const V1ThreadRoutes = express.Router();
V1ThreadRoutes.post( V1ThreadRoutes.post("/upsetThread/", tokenValidator, threadCreate);
"/upsetThread/", V1ThreadRoutes.patch("/Thread/delete", tokenValidator, threaddelete);
tokenValidator, V1ThreadRoutes.patch("/Thread/updateTitle", tokenValidator, threadUpdateTitle);
threadCreate V1ThreadRoutes.post("/Thread/addComment", tokenValidator, threadComment);
);
V1ThreadRoutes.patch(
"/Thread/delete",
tokenValidator,
threaddelete
);
V1ThreadRoutes.patch(
"/Thread/updateTitle",
tokenValidator,
threadUpdateTitle
);
V1ThreadRoutes.post(
"/Thread/addComment",
tokenValidator,
threadComment
);
V1ThreadRoutes.patch( V1ThreadRoutes.patch(
"/Thread/deleteComment", "/Thread/deleteComment",
tokenValidator, tokenValidator,
threadCommentDelete threadCommentDelete
); );
V1ThreadRoutes.get( V1ThreadRoutes.get(
"/Threads/:projectId", "/Threads/:projectId/:versionId",
tokenValidator, tokenValidator,
getALLthreads getALLthreads
); );
export default V1ThreadRoutes export default V1ThreadRoutes;

View File

@@ -7,6 +7,7 @@ export interface Token extends Document {
refreshToken: string; refreshToken: string;
resetTokenExpiry?: Date; resetTokenExpiry?: Date;
resetToken: string; resetToken: string;
role: string;
} }
const tokenSchema: Schema = new Schema({ const tokenSchema: Schema = new Schema({
userId: { type: Schema.Types.ObjectId, ref: "User" }, userId: { type: Schema.Types.ObjectId, ref: "User" },

View File

@@ -12,6 +12,10 @@ const AuthSchema: Schema = new Schema({
userName: { userName: {
type: String, type: String,
required: true, required: true,
},role: {
type: String,
default: "User",
enum: ["User", "Admin"],
}, },
Email: { Email: {
type: String, type: String,

View File

@@ -7,7 +7,7 @@ interface IComment {
userId: User["_id"]; userId: User["_id"];
comment: string; comment: string;
isArchive: boolean; isArchive: boolean;
createdAt: number createdAt: number;
} }
export interface IThread extends Document { export interface IThread extends Document {
projectId: Project["_id"]; projectId: Project["_id"];
@@ -22,28 +22,26 @@ export interface IThread extends Document {
comments: IComment[]; comments: IComment[];
isArchive: boolean; isArchive: boolean;
isResolved: boolean; isResolved: boolean;
} }
const CommentSchema = new Schema<IComment>( const CommentSchema = new Schema<IComment>({
{ userId: { type: Schema.Types.ObjectId, ref: "User", required: true },
userId: { type: Schema.Types.ObjectId, ref: 'User', required: true }, comment: { type: String },
comment: { type: String, }, isArchive: { type: Boolean, default: false },
isArchive: { type: Boolean, default: false }, createdAt: {
createdAt: { type: Number,
type: Number, default: Date.now(),
default: Date.now()
}
}, },
); });
const threadSchema = new Schema<IThread>({ const threadSchema = new Schema<IThread>({
projectId: { type: Schema.Types.ObjectId, ref: 'Project', required: true }, projectId: { type: Schema.Types.ObjectId, ref: "Project", required: true },
state: { type: String, enum: ['active', 'inactive'], required: true }, versionId: { type: Schema.Types.ObjectId, ref: "Version", required: true },
threadTitle: { type: String, }, state: { type: String, enum: ["active", "inactive"], required: true },
createdBy: { type: Schema.Types.ObjectId, ref: 'User', required: true }, threadTitle: { type: String },
createdAt: { type: Number, }, createdBy: { type: Schema.Types.ObjectId, ref: "User", required: true },
createdAt: { type: Number },
isArchive: { type: Boolean, default: false }, isArchive: { type: Boolean, default: false },
isResolved: { type: Boolean, default: false }, isResolved: { type: Boolean, default: false },
lastUpdatedAt: { type: String, }, lastUpdatedAt: { type: String },
position: { position: {
type: [Number], type: [Number],
required: true, required: true,
@@ -58,4 +56,4 @@ const threadSchema = new Schema<IThread>({
const ThreadModel = (db: string) => { const ThreadModel = (db: string) => {
return MainModel(db, "Threads", threadSchema, "Threads"); return MainModel(db, "Threads", threadSchema, "Threads");
}; };
export default ThreadModel; export default ThreadModel;

View File

@@ -32,6 +32,7 @@ interface IComment {
interface IgetThread { interface IgetThread {
projectId: string; projectId: string;
versionId: string;
userId: string; userId: string;
organization: string; organization: string;
} }
@@ -39,6 +40,7 @@ export const createThread = async (data: IThread) => {
try { try {
const { const {
projectId, projectId,
versionId,
state, state,
userId, userId,
position, position,
@@ -46,6 +48,7 @@ export const createThread = async (data: IThread) => {
threadTitle, threadTitle,
organization, organization,
} = data; } = data;
console.log('data;: ', data);
const userExisting = await existingUser(userId, organization); const userExisting = await existingUser(userId, organization);
if (!userExisting) { if (!userExisting) {
return { return {
@@ -60,15 +63,15 @@ export const createThread = async (data: IThread) => {
if (!projectExisting) { if (!projectExisting) {
return { status: "Project not found" }; return { status: "Project not found" };
} }
const currentVersion = await LivingCurrentVersion( const ExistingVersion = await LivingCurrentVersion(
organization, organization,
projectExisting._id, projectExisting._id,
projectExisting.Present_version versionId
); );
if (!currentVersion) return { status: "CurrentVersion Data not found" }; if (!ExistingVersion) return { status: "Version Data not found" };
const newThread = await ThreadModel(organization).create({ const newThread = await ThreadModel(organization).create({
projectId, projectId,
versionId: currentVersion._id, versionId: versionId,
state, state,
createdBy: userId, createdBy: userId,
position, position,
@@ -77,6 +80,7 @@ export const createThread = async (data: IThread) => {
isArchive: false, isArchive: false,
createdAt: Date.now(), createdAt: Date.now(),
}); });
console.log('newThread: ', newThread);
const responseData = { const responseData = {
_id: newThread._id, _id: newThread._id,
projectId: newThread.projectId, projectId: newThread.projectId,
@@ -101,7 +105,7 @@ export const createThread = async (data: IThread) => {
}; };
export const deleteThread = async (data: IThread) => { export const deleteThread = async (data: IThread) => {
try { try {
const { projectId, userId, organization, threadId } = data; const { projectId, userId, versionId, organization, threadId } = data;
const userExisting = await existingUser(userId, organization); const userExisting = await existingUser(userId, organization);
if (!userExisting) { if (!userExisting) {
return { return {
@@ -116,12 +120,12 @@ export const deleteThread = async (data: IThread) => {
if (!projectExisting) { if (!projectExisting) {
return { status: "Project not found" }; return { status: "Project not found" };
} }
const currentVersion = await LivingCurrentVersion( const ExistingVersion = await LivingCurrentVersion(
organization, organization,
projectExisting._id, projectExisting._id,
projectExisting.Present_version versionId
); );
if (!currentVersion) return { status: "CurrentVersion Data not found" }; if (!ExistingVersion) return { status: "Version Data not found" };
const findThreadId = await ThreadModel(organization).findOne({ const findThreadId = await ThreadModel(organization).findOne({
_id: threadId, _id: threadId,
createdBy: userId, createdBy: userId,
@@ -147,6 +151,7 @@ export const updateThreadTitle = async (data: IThread) => {
try { try {
const { const {
projectId, projectId,
versionId,
userId, userId,
threadTitle, threadTitle,
organization, organization,
@@ -168,12 +173,12 @@ export const updateThreadTitle = async (data: IThread) => {
if (!projectExisting) { if (!projectExisting) {
return { status: "Project not found" }; return { status: "Project not found" };
} }
const currentVersion = await LivingCurrentVersion( const ExistingVersion = await LivingCurrentVersion(
organization, organization,
projectExisting._id, projectExisting._id,
projectExisting.Present_version versionId
); );
if (!currentVersion) return { status: "CurrentVersion Data not found" }; if (!ExistingVersion) return { status: "Version Data not found" };
const findThreadId = await ThreadModel(organization).findById(threadId); const findThreadId = await ThreadModel(organization).findById(threadId);
if (findThreadId) { if (findThreadId) {
const updateThread = await ThreadModel(organization).findOneAndUpdate( const updateThread = await ThreadModel(organization).findOneAndUpdate(
@@ -200,8 +205,15 @@ export const updateThreadTitle = async (data: IThread) => {
}; };
export const addComments = async (data: IThread) => { export const addComments = async (data: IThread) => {
try { try {
const { projectId, userId, comment, organization, threadId, commentId } = const {
data; projectId,
versionId,
userId,
comment,
organization,
threadId,
commentId,
} = data;
const userExisting = await existingUser(userId, organization); const userExisting = await existingUser(userId, organization);
if (!userExisting) { if (!userExisting) {
return { return {
@@ -216,12 +228,12 @@ export const addComments = async (data: IThread) => {
if (!projectExisting) { if (!projectExisting) {
return { status: "Project not found" }; return { status: "Project not found" };
} }
const currentVersion = await LivingCurrentVersion( const ExistingVersion = await LivingCurrentVersion(
organization, organization,
projectExisting._id, projectExisting._id,
projectExisting.Present_version versionId
); );
if (!currentVersion) return { status: "CurrentVersion Data not found" }; if (!ExistingVersion) return { status: "Version Data not found" };
const findThreadId = await ThreadModel(organization).findById(threadId); const findThreadId = await ThreadModel(organization).findById(threadId);
if (commentId) { if (commentId) {
const updated = await ThreadModel(organization).findOneAndUpdate( const updated = await ThreadModel(organization).findOneAndUpdate(
@@ -276,7 +288,8 @@ export const addComments = async (data: IThread) => {
}; };
export const deleteComments = async (data: IThread) => { export const deleteComments = async (data: IThread) => {
try { try {
const { projectId, userId, commentId, organization, threadId } = data; const { projectId, versionId, userId, commentId, organization, threadId } =
data;
const userExisting = await existingUser(userId, organization); const userExisting = await existingUser(userId, organization);
if (!userExisting) { if (!userExisting) {
return { return {
@@ -291,12 +304,12 @@ export const deleteComments = async (data: IThread) => {
if (!projectExisting) { if (!projectExisting) {
return { status: "Project not found" }; return { status: "Project not found" };
} }
const currentVersion = await LivingCurrentVersion( const ExistingVersion = await LivingCurrentVersion(
organization, organization,
projectExisting._id, projectExisting._id,
projectExisting.Present_version versionId
); );
if (!currentVersion) return { status: "CurrentVersion Data not found" }; if (!ExistingVersion) return { status: "Version Data not found" };
const findThreadId = await ThreadModel(organization).findOne({ const findThreadId = await ThreadModel(organization).findOne({
_id: threadId, _id: threadId,
}); });
@@ -330,7 +343,7 @@ export const deleteComments = async (data: IThread) => {
}; };
export const findThreads = async (data: IgetThread) => { export const findThreads = async (data: IgetThread) => {
try { try {
const { projectId, userId, organization } = data; const { projectId, versionId, userId, organization } = data;
const userExisting = await existingUser(userId, organization); const userExisting = await existingUser(userId, organization);
if (!userExisting) { if (!userExisting) {
return { return {
@@ -345,14 +358,17 @@ export const findThreads = async (data: IgetThread) => {
if (!projectExisting) { if (!projectExisting) {
return { status: "Project not found" }; return { status: "Project not found" };
} }
const currentVersion = await LivingCurrentVersion( const VersionGetId = versionId
? versionId
: projectExisting.Present_version;
const ExistingVersion = await LivingCurrentVersion(
organization, organization,
projectExisting._id, projectExisting._id,
projectExisting.Present_version VersionGetId
); );
if (!currentVersion) return { status: "CurrentVersion Data not found" }; if (!ExistingVersion) return { status: "Version Data not found" };
const findThreads = await ThreadModel(organization) const findThreads = await ThreadModel(organization)
.find({ isArchive: false, projectId, versionId: currentVersion._id }) .find({ isArchive: false, projectId, versionId: versionId })
.lean(); .lean();
const formattedThreads = findThreads.map((thread) => { const formattedThreads = findThreads.map((thread) => {

View File

@@ -62,11 +62,12 @@ export const AuthSignup = async (
const newuser = await AuthModel(organization).create({ const newuser = await AuthModel(organization).create({
userName: userName, userName: userName,
Email: caseChange, Email: caseChange,
role: role,
Password: hashPassword, Password: hashPassword,
}); });
await UsersDataModel(organization).create({ await UsersDataModel(organization).create({
userId: newuser._id, userId: newuser._id,
role: role, // role: role,
isShare: isShare, isShare: isShare,
profilePicture: profilePicture, profilePicture: profilePicture,
}); });

View File

@@ -33,6 +33,7 @@ export const createThreadHandleEvent = async (
"rotation", "rotation",
"organization", "organization",
"projectId", "projectId",
"versionId",
]; ];
const missingFields = validateFields(data, requiredFields); const missingFields = validateFields(data, requiredFields);
@@ -55,8 +56,8 @@ export const createThreadHandleEvent = async (
Success: { message: "Thread created Successfully" }, Success: { message: "Thread created Successfully" },
"User not found": { message: "User not found" }, "User not found": { message: "User not found" },
"Project not found": { message: "Project not found" }, "Project not found": { message: "Project not found" },
"CurrentVersion Data not found": { "Version Data not found": {
message: "CurrentVersion Data not found", message: "Version Data not found",
}, },
}; };
const msg = messages[status] || { message: "Internal server error" }; const msg = messages[status] || { message: "Internal server error" };
@@ -99,7 +100,13 @@ export const deleteThreadHandleEvent = async (
} }
) => { ) => {
if (event !== EVENTS.deleteThread || !data?.organization) return; if (event !== EVENTS.deleteThread || !data?.organization) return;
const requiredFields = ["userId", "threadId", "organization", "projectId"]; const requiredFields = [
"userId",
"threadId",
"organization",
"projectId",
"versionId",
];
const missingFields = validateFields(data, requiredFields); const missingFields = validateFields(data, requiredFields);
if (missingFields.length > 0) { if (missingFields.length > 0) {
@@ -121,8 +128,8 @@ export const deleteThreadHandleEvent = async (
Success: { message: "Thread deleted Successfully" }, Success: { message: "Thread deleted Successfully" },
"User not found": { message: "User not found" }, "User not found": { message: "User not found" },
"Project not found": { message: "Project not found" }, "Project not found": { message: "Project not found" },
"CurrentVersion Data not found": { "Version Data not found": {
message: "CurrentVersion Data not found", message: "Version Data not found",
}, },
"can't deleted": { message: "Thread could not be deleted" }, "can't deleted": { message: "Thread could not be deleted" },
}; };
@@ -155,7 +162,13 @@ export const addCommentHandleEvent = async (
} }
) => { ) => {
if (event !== EVENTS.addComment || !data?.organization) return; if (event !== EVENTS.addComment || !data?.organization) return;
const requiredFields = ["userId", "organization", "threadId", "projectId"]; const requiredFields = [
"userId",
"versionId",
"organization",
"threadId",
"projectId",
];
const missingFields = validateFields(data, requiredFields); const missingFields = validateFields(data, requiredFields);
@@ -178,8 +191,8 @@ export const addCommentHandleEvent = async (
Success: { message: "Thread comments add Successfully" }, Success: { message: "Thread comments add Successfully" },
"User not found": { message: "User not found" }, "User not found": { message: "User not found" },
"Project not found": { message: "Project not found" }, "Project not found": { message: "Project not found" },
"CurrentVersion Data not found": { "Version Data not found": {
message: "CurrentVersion Data not found", message: "Version Data not found",
}, },
updated: { message: "Comment updated successfully" }, updated: { message: "Comment updated successfully" },
}; };
@@ -215,7 +228,13 @@ export const deleteCommentHandleEvent = async (
} }
) => { ) => {
if (event !== EVENTS.deleteComment || !data?.organization) return; if (event !== EVENTS.deleteComment || !data?.organization) return;
const requiredFields = ["userId", "organization", "commentId", "projectId"]; const requiredFields = [
"userId",
"versionId",
"organization",
"commentId",
"projectId",
];
const missingFields = validateFields(data, requiredFields); const missingFields = validateFields(data, requiredFields);
@@ -237,8 +256,8 @@ export const deleteCommentHandleEvent = async (
Success: { message: "Thread comment deleted Successfully" }, Success: { message: "Thread comment deleted Successfully" },
"User not found": { message: "User not found" }, "User not found": { message: "User not found" },
"Project not found": { message: "Project not found" }, "Project not found": { message: "Project not found" },
"CurrentVersion Data not found": { "Version Data not found": {
message: "CurrentVersion Data not found", message: "Version Data not found",
}, },
unauthorized: { message: "You can only delete your own comment." }, unauthorized: { message: "You can only delete your own comment." },
"thread not found": { message: "thread not found" }, "thread not found": { message: "thread not found" },
@@ -272,7 +291,13 @@ export const threadUpdateHandleEvent = async (
} }
) => { ) => {
if (event !== EVENTS.updateThreat || !data?.organization) return; if (event !== EVENTS.updateThreat || !data?.organization) return;
const requiredFields = ["userId", "organization", "threadId", "projectId"]; const requiredFields = [
"userId",
"versionId",
"organization",
"threadId",
"projectId",
];
const missingFields = validateFields(data, requiredFields); const missingFields = validateFields(data, requiredFields);
if (missingFields.length > 0) { if (missingFields.length > 0) {
@@ -293,8 +318,8 @@ export const threadUpdateHandleEvent = async (
Success: { message: "ThreadTitle updated Successfully" }, Success: { message: "ThreadTitle updated Successfully" },
"User not found": { message: "User not found" }, "User not found": { message: "User not found" },
"Project not found": { message: "Project not found" }, "Project not found": { message: "Project not found" },
"CurrentVersion Data not found": { "Version Data not found": {
message: "CurrentVersion Data not found", message: "Version Data not found",
}, },
}; };
const msg = messages[status] || { message: "Internal server error" }; const msg = messages[status] || { message: "Internal server error" };