using the same API for email UI and sending email
This commit is contained in:
@ -262,27 +262,35 @@ export default async function handler(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
let subscribedPublishers = [], availablePublishers = [];
|
||||
if (toSubscribed) {
|
||||
//get all subscribed publisers
|
||||
subscribedPublishers = await prisma.publisher.findMany({
|
||||
where: {
|
||||
isSubscribedToCoverMe: true
|
||||
}
|
||||
});
|
||||
let targetEmails = await data.getCoverMePublisherEmails(assignment.shift.id);
|
||||
if (!toSubscribed) {
|
||||
targetEmails.subscribedPublishers = [];
|
||||
}
|
||||
if (!toAvailable) {
|
||||
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);
|
||||
|
||||
}
|
||||
// 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 = subscribedPublishers.concat(availablePublishers).
|
||||
let pubsToSend = targetEmails.subscribedPublishers.concat(targetEmails.availablePublishers).
|
||||
filter((item, index, self) =>
|
||||
index === self.findIndex((t) => (
|
||||
t.email === item.email && item.email !== publisher.email//and exclude the user himself
|
||||
|
Reference in New Issue
Block a user