fix logging messages
This commit is contained in:
@ -31,9 +31,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const targetTable = req.query.nextcrud[0];
|
||||
//get target action
|
||||
if (req.method === 'DELETE') {
|
||||
|
||||
const targetId = req.query.nextcrud[1];
|
||||
logger.info('[nextCrud] ' + targetTable + ': ' + targetId + 'DELETED by ' + session.user.email);
|
||||
switch (targetTable) {
|
||||
case 'publishers':
|
||||
const targetId = req.query.nextcrud[1];
|
||||
logger.info('[nextCrud] ' + targetTable + ': ' + targetId + ' DELETED by ' + session.user.email);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nextCrudHandler(req, res);
|
||||
}
|
||||
|
@ -230,7 +230,6 @@ export default async function handler(req, res) {
|
||||
let toSubscribed = req.body.toSubscribed;
|
||||
let toAvailable = req.body.toAvailable;
|
||||
|
||||
|
||||
let assignment = await prisma.assignment.findUnique({
|
||||
where: {
|
||||
id: parseInt(assignmentId)
|
||||
@ -248,7 +247,6 @@ export default async function handler(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// update the assignment. generate new publicGuid, isConfirmed to false
|
||||
let newPublicGuid = uuidv4();
|
||||
await prisma.assignment.update({
|
||||
@ -269,25 +267,6 @@ export default async function handler(req, res) {
|
||||
targetEmails.availablePublishers = [];
|
||||
}
|
||||
|
||||
// let subscribedPublishers = targetEmails.subscribedPublishers, availablePublishers = [];
|
||||
// if (toSubscribed) {
|
||||
// //get all subscribed publisers
|
||||
// subscribedPublishers = await prisma.publisher.findMany({
|
||||
// where: {
|
||||
// isSubscribedToCoverMe: true
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// if (toAvailable) {
|
||||
// availablePublishers = await data.filterPublishersNew("id,firstName,lastName,email", new Date(assignment.shift.startTime),
|
||||
// true, false);
|
||||
|
||||
// }
|
||||
// use
|
||||
|
||||
|
||||
//concat and remove duplicate emails
|
||||
let pubsToSend = targetEmails.subscribedPublishers.concat(targetEmails.availablePublishers).
|
||||
filter((item, index, self) =>
|
||||
@ -301,10 +280,10 @@ export default async function handler(req, res) {
|
||||
data: {
|
||||
date: new Date(),
|
||||
publisher: { connect: { id: publisher.id } },
|
||||
shift: { connect: { id: assignment.shiftId } },
|
||||
shift: { connect: { id: assignment.shift.id } },
|
||||
type: EventLogType.AssignmentReplacementRequested,
|
||||
content: "Заявка за заместване от " + publisher.firstName + " " + publisher.lastName
|
||||
+ "до: " + pubsToSend.map(p => p.firstName + " " + p.lastName + "<" + p.email + ">").join(", "),
|
||||
+ " до: " + pubsToSend.map(p => p.firstName + " " + p.lastName + "<" + p.email + ">").join(", "),
|
||||
}
|
||||
});
|
||||
logger.info("User: " + publisher.email + " sent a 'CoverMe' request for his assignment " + assignmentId + " - " + assignment.shift.cartEvent.location.name + " " + assignment.shift.startTime.toISOString() + " to " + pubsToSend.map(p => p.firstName + " " + p.lastName + "<" + p.email + ">").join(", ") + ". EventLogId: " + eventLog.id + "");
|
||||
@ -313,12 +292,12 @@ export default async function handler(req, res) {
|
||||
for (let i = 0; i < pubsToSend.length; i++) {
|
||||
|
||||
//send email to subscribed publisher
|
||||
let acceptUrl = process.env.NEXTAUTH_URL + "/api/email?action=email_response&emailaction=coverMeAccept&userId=" + pubsToSend[i].id + "&shiftId=" + assignment.shiftId + "&assignmentPID=" + newPublicGuid;
|
||||
let acceptUrl = process.env.NEXTAUTH_URL + "/api/email?action=email_response&emailaction=coverMeAccept&userId=" + pubsToSend[i].id + "&shiftId=" + assignment.shift.id + "&assignmentPID=" + newPublicGuid;
|
||||
publisher.prefix = publisher.isMale ? "Брат" : "Сестра";
|
||||
|
||||
let model = {
|
||||
user: publisher,
|
||||
shiftId: assignment.shiftId,
|
||||
shiftId: assignment.shift.id,
|
||||
acceptUrl: acceptUrl,
|
||||
firstName: pubsToSend[i].firstName,
|
||||
lastName: pubsToSend[i].lastName,
|
||||
@ -350,7 +329,6 @@ export default async function handler(req, res) {
|
||||
return res.status(400).json({ message: "Invalid action" });
|
||||
}
|
||||
|
||||
return res.status(200).json({ message: "User action processed" });
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user