!role All fields are required updated
This commit is contained in:
@@ -66,14 +66,14 @@ export const GetProjects = async (
|
|||||||
res: Response
|
res: Response
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization, role } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
if (!userId || !organization || !role) {
|
if (!userId || !organization) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await GetAllProjects({ userId, organization, role });
|
const result = await GetAllProjects({ userId, organization });
|
||||||
switch (result?.status) {
|
switch (result?.status) {
|
||||||
case "User not found":
|
case "User not found":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
@@ -158,7 +158,7 @@ export const updateProjectController = async (
|
|||||||
const { userId, organization, role } = req.user || {};
|
const { userId, organization, role } = req.user || {};
|
||||||
const { projectId } = req.params;
|
const { projectId } = req.params;
|
||||||
const { projectName, thumbnail } = req.body;
|
const { projectName, thumbnail } = req.body;
|
||||||
if (!userId || !organization || !projectId || !role) {
|
if (!userId || !organization || !projectId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -170,7 +170,6 @@ export const updateProjectController = async (
|
|||||||
userId,
|
userId,
|
||||||
projectName,
|
projectName,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
role,
|
|
||||||
});
|
});
|
||||||
switch (result?.status) {
|
switch (result?.status) {
|
||||||
case "Project not found":
|
case "Project not found":
|
||||||
@@ -215,7 +214,7 @@ export const ViewData = async (
|
|||||||
const { projectId } = req.params as {
|
const { projectId } = req.params as {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
};
|
};
|
||||||
if (!userId || !organization || !projectId || !role) {
|
if (!userId || !organization || !projectId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -225,7 +224,6 @@ export const ViewData = async (
|
|||||||
projectId,
|
projectId,
|
||||||
organization,
|
organization,
|
||||||
userId,
|
userId,
|
||||||
role,
|
|
||||||
});
|
});
|
||||||
switch (result?.status) {
|
switch (result?.status) {
|
||||||
case "Project not found":
|
case "Project not found":
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ export const GetTrashList = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, role, userId } = req.user || {};
|
const { organization, role, userId } = req.user || {};
|
||||||
if (!organization || !role || !userId) {
|
if (!organization || !userId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await TrashDatas({ organization, role, userId });
|
const result = await TrashDatas({ organization, userId });
|
||||||
|
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
case "User not found":
|
case "User not found":
|
||||||
@@ -60,7 +60,7 @@ export const RestoreTrash = async (
|
|||||||
const { projectId } = req.query as {
|
const { projectId } = req.query as {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
};
|
};
|
||||||
if (!organization || !projectId || !role || !userId) {
|
if (!organization || !projectId || !userId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -69,7 +69,6 @@ export const RestoreTrash = async (
|
|||||||
const result = await RestoreTrashData({
|
const result = await RestoreTrashData({
|
||||||
organization,
|
organization,
|
||||||
projectId,
|
projectId,
|
||||||
role,
|
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -116,7 +115,7 @@ export const DeleteTrashData = async (
|
|||||||
const { projectId } = req.query as {
|
const { projectId } = req.query as {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
};
|
};
|
||||||
if (!organization || !projectId || !role || !userId) {
|
if (!organization || !projectId || !userId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -125,7 +124,6 @@ export const DeleteTrashData = async (
|
|||||||
const result = await TrashDelete({
|
const result = await TrashDelete({
|
||||||
organization,
|
organization,
|
||||||
projectId,
|
projectId,
|
||||||
role,
|
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const versionAddcontroller = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, role, userId } = req.user || {};
|
const { organization, role, userId } = req.user || {};
|
||||||
if (!organization || !role || !userId) {
|
if (!organization || !userId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -69,7 +69,7 @@ export const GetversionList = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, role, userId } = req.user || {};
|
const { organization, role, userId } = req.user || {};
|
||||||
if (!organization || !role || !userId) {
|
if (!organization || !userId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -121,7 +121,7 @@ export const rollbackcontroller = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, role, userId } = req.user || {};
|
const { organization, role, userId } = req.user || {};
|
||||||
if (!organization || !role || !userId) {
|
if (!organization || !userId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -176,7 +176,7 @@ export const GetversionHistory = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { organization, role, userId } = req.user || {};
|
const { organization, role, userId } = req.user || {};
|
||||||
if (!organization || !role || !userId) {
|
if (!organization || !userId) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
|
|
||||||
interface IThread {
|
interface IThread {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
|
isArchive?: boolean;
|
||||||
versionId: string;
|
versionId: string;
|
||||||
state: string;
|
state: string;
|
||||||
commentId: string;
|
commentId: string;
|
||||||
@@ -48,7 +49,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 {
|
||||||
@@ -80,7 +81,6 @@ 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,
|
||||||
@@ -88,7 +88,6 @@ export const createThread = async (data: IThread) => {
|
|||||||
state: newThread.state,
|
state: newThread.state,
|
||||||
createdBy: newThread.createdBy,
|
createdBy: newThread.createdBy,
|
||||||
createdAt: newThread.createdAt,
|
createdAt: newThread.createdAt,
|
||||||
isArchive: newThread.isArchive,
|
|
||||||
position: newThread.position,
|
position: newThread.position,
|
||||||
rotation: newThread.rotation,
|
rotation: newThread.rotation,
|
||||||
threadTitle: newThread.threadTitle,
|
threadTitle: newThread.threadTitle,
|
||||||
@@ -129,14 +128,25 @@ export const deleteThread = async (data: IThread) => {
|
|||||||
const findThreadId = await ThreadModel(organization).findOne({
|
const findThreadId = await ThreadModel(organization).findOne({
|
||||||
_id: threadId,
|
_id: threadId,
|
||||||
createdBy: userId,
|
createdBy: userId,
|
||||||
|
isArchive: false,
|
||||||
|
versionId,
|
||||||
|
projectId,
|
||||||
});
|
});
|
||||||
if (!findThreadId) {
|
if (!findThreadId) {
|
||||||
return { status: "can't deleted" };
|
return { status: "can't deleted" };
|
||||||
}
|
}
|
||||||
const deleteThread = await ThreadModel(organization).findOneAndUpdate(
|
const deleteThread = await ThreadModel(organization)
|
||||||
{ _id: threadId, createdBy: userId },
|
.findOneAndUpdate(
|
||||||
{ isArchive: true }
|
{
|
||||||
);
|
_id: threadId,
|
||||||
|
createdBy: userId,
|
||||||
|
versionId,
|
||||||
|
projectId,
|
||||||
|
isArchive: false,
|
||||||
|
},
|
||||||
|
{ isArchive: true }
|
||||||
|
)
|
||||||
|
.select("-isArchive -__v");
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
data: deleteThread,
|
data: deleteThread,
|
||||||
@@ -158,6 +168,7 @@ export const updateThreadTitle = async (data: IThread) => {
|
|||||||
threadId,
|
threadId,
|
||||||
commentId,
|
commentId,
|
||||||
} = data;
|
} = data;
|
||||||
|
console.log("data: ", data);
|
||||||
|
|
||||||
const userExisting = await existingUser(userId, organization);
|
const userExisting = await existingUser(userId, organization);
|
||||||
if (!userExisting) {
|
if (!userExisting) {
|
||||||
@@ -179,19 +190,26 @@ export const updateThreadTitle = async (data: IThread) => {
|
|||||||
versionId
|
versionId
|
||||||
);
|
);
|
||||||
if (!ExistingVersion) return { status: "Version Data not found" };
|
if (!ExistingVersion) return { status: "Version Data not found" };
|
||||||
const findThreadId = await ThreadModel(organization).findById(threadId);
|
const findThreadId = await ThreadModel(organization).findById({
|
||||||
|
_id: threadId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
if (findThreadId) {
|
if (findThreadId) {
|
||||||
const updateThread = await ThreadModel(organization).findOneAndUpdate(
|
const updateThread = await ThreadModel(organization)
|
||||||
{
|
.findOneAndUpdate(
|
||||||
_id: threadId,
|
{
|
||||||
createdBy: userId,
|
_id: threadId,
|
||||||
},
|
isArchive: false,
|
||||||
{ threadTitle: threadTitle },
|
versionId,
|
||||||
{
|
projectId,
|
||||||
new: true,
|
createdBy: userId,
|
||||||
}
|
},
|
||||||
);
|
{ threadTitle: threadTitle },
|
||||||
|
{
|
||||||
|
new: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.select("-isArchive -__v");
|
||||||
return {
|
return {
|
||||||
status: "Success",
|
status: "Success",
|
||||||
data: updateThread,
|
data: updateThread,
|
||||||
@@ -234,23 +252,31 @@ export const addComments = async (data: IThread) => {
|
|||||||
versionId
|
versionId
|
||||||
);
|
);
|
||||||
if (!ExistingVersion) return { status: "Version Data not found" };
|
if (!ExistingVersion) return { status: "Version Data not found" };
|
||||||
const findThreadId = await ThreadModel(organization).findById(threadId);
|
const findThreadId = await ThreadModel(organization).findById({
|
||||||
|
_id: threadId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
if (commentId) {
|
if (commentId) {
|
||||||
const updated = await ThreadModel(organization).findOneAndUpdate(
|
const updated = await ThreadModel(organization)
|
||||||
{
|
.findOneAndUpdate(
|
||||||
_id: threadId,
|
{
|
||||||
"comments._id": commentId,
|
_id: threadId,
|
||||||
},
|
isArchive: false,
|
||||||
{
|
versionId,
|
||||||
$set: {
|
projectId,
|
||||||
"comments.$.comment": comment,
|
"comments._id": commentId,
|
||||||
"comments.$.createdAt": Date.now(),
|
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
$set: {
|
||||||
new: true,
|
"comments.$.comment": comment,
|
||||||
}
|
"comments.$.createdAt": Date.now(),
|
||||||
);
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
new: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.select("-isArchive -__v");
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
const updatedComment = updated?.comments?.find(
|
const updatedComment = updated?.comments?.find(
|
||||||
@@ -312,6 +338,8 @@ export const deleteComments = async (data: IThread) => {
|
|||||||
if (!ExistingVersion) return { status: "Version 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,
|
||||||
|
versionId,
|
||||||
|
projectId,
|
||||||
});
|
});
|
||||||
if (!findThreadId) {
|
if (!findThreadId) {
|
||||||
return { status: "thread not found" };
|
return { status: "thread not found" };
|
||||||
@@ -320,6 +348,9 @@ export const deleteComments = async (data: IThread) => {
|
|||||||
const deleted = await ThreadModel(organization).findOneAndUpdate(
|
const deleted = await ThreadModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
_id: threadId,
|
_id: threadId,
|
||||||
|
isArchive: false,
|
||||||
|
versionId,
|
||||||
|
projectId,
|
||||||
"comments._id": commentId,
|
"comments._id": commentId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -328,7 +359,7 @@ export const deleteComments = async (data: IThread) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
new: true, // returns the updated document
|
new: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -42,12 +42,10 @@ interface UpdateProjectInput {
|
|||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization: string;
|
organization: string;
|
||||||
role: string;
|
|
||||||
}
|
}
|
||||||
interface GetProjectsInterface {
|
interface GetProjectsInterface {
|
||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
role: string;
|
|
||||||
}
|
}
|
||||||
interface ProjectDelInterface {
|
interface ProjectDelInterface {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
@@ -58,7 +56,6 @@ interface ProjectInterface {
|
|||||||
projectId: string;
|
projectId: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
role: string;
|
|
||||||
}
|
}
|
||||||
interface RoleFilter {
|
interface RoleFilter {
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
|
|||||||
@@ -2,13 +2,11 @@ import projectModel from "../../V1Models/Project/project-model.ts";
|
|||||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||||
interface IOrg {
|
interface IOrg {
|
||||||
organization: string;
|
organization: string;
|
||||||
role: string;
|
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
interface IRestore {
|
interface IRestore {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
role: string;
|
|
||||||
userId: string;
|
userId: string;
|
||||||
}
|
}
|
||||||
interface RoleFilter {
|
interface RoleFilter {
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ export const deleteThreadHandleEvent = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await deleteThread(data);
|
const result = await deleteThread(data);
|
||||||
|
console.log("result: ", result);
|
||||||
const status = typeof result?.status === "string" ? result.status : "unknown";
|
const status = typeof result?.status === "string" ? result.status : "unknown";
|
||||||
|
|
||||||
const messages: Record<string, { message: string }> = {
|
const messages: Record<string, { message: string }> = {
|
||||||
@@ -143,6 +144,7 @@ export const deleteThreadHandleEvent = async (
|
|||||||
messages,
|
messages,
|
||||||
threadDatas
|
threadDatas
|
||||||
);
|
);
|
||||||
|
|
||||||
emitToSenderAndAdmins(
|
emitToSenderAndAdmins(
|
||||||
io,
|
io,
|
||||||
socket,
|
socket,
|
||||||
|
|||||||
Reference in New Issue
Block a user