tweak email template model, fix EventLog content size, etc...
This commit is contained in:
@ -279,8 +279,8 @@ export default async function handler(req, res) {
|
|||||||
let pubsToSend = subscribedPublishers.concat(availablePublishers).
|
let pubsToSend = subscribedPublishers.concat(availablePublishers).
|
||||||
filter((item, index, self) =>
|
filter((item, index, self) =>
|
||||||
index === self.findIndex((t) => (
|
index === self.findIndex((t) => (
|
||||||
t.email === item.email //and exclude the user himself
|
t.email === item.email && item.email !== publisher.email//and exclude the user himself
|
||||||
)) //&& item.email !== publisher.email
|
))
|
||||||
);
|
);
|
||||||
console.log("Sending CoverMe request to " + pubsToSend.length + " publishers");
|
console.log("Sending CoverMe request to " + pubsToSend.length + " publishers");
|
||||||
|
|
||||||
@ -294,17 +294,18 @@ export default async function handler(req, res) {
|
|||||||
+ "до: " + pubsToSend.map(p => p.firstName + " " + p.lastName + "<" + p.email + ">").join(", "),
|
+ "до: " + pubsToSend.map(p => p.firstName + " " + p.lastName + "<" + p.email + ">").join(", "),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//send email to all subscribed publishers
|
//send email to all subscribed publishers
|
||||||
for (let i = 0; i < pubsToSend.length; i++) {
|
for (let i = 0; i < pubsToSend.length; i++) {
|
||||||
|
|
||||||
//send email to subscribed publisher
|
//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.shiftId + "&assignmentPID=" + newPublicGuid;
|
||||||
|
publisher.prefix = publisher.isMale ? "Брат" : "Сестра";
|
||||||
|
|
||||||
let model = {
|
let model = {
|
||||||
user: publisher,
|
user: publisher,
|
||||||
shiftId: assignment.shiftId,
|
shiftId: assignment.shiftId,
|
||||||
acceptUrl: acceptUrl,
|
acceptUrl: acceptUrl,
|
||||||
prefix: publisher.isMale ? "Брат" : "Сестра",
|
|
||||||
firstName: pubsToSend[i].firstName,
|
firstName: pubsToSend[i].firstName,
|
||||||
lastName: pubsToSend[i].lastName,
|
lastName: pubsToSend[i].lastName,
|
||||||
email: pubsToSend[i].email,
|
email: pubsToSend[i].email,
|
||||||
|
@ -205,7 +205,7 @@ export const getServerSideProps = async (context) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const assignments = publisher?.assignments || [];
|
const assignments = publisher?.assignments.filter(assignment => assignment.shift.startTime >= lastSunday) || [];
|
||||||
|
|
||||||
const transformedAssignments = assignments?.map(assignment => {
|
const transformedAssignments = assignments?.map(assignment => {
|
||||||
if (assignment.shift && assignment.shift.startTime) {
|
if (assignment.shift && assignment.shift.startTime) {
|
||||||
|
@ -4,7 +4,7 @@ CREATE TABLE `EventLog` (
|
|||||||
`date` DATETIME(3) NOT NULL,
|
`date` DATETIME(3) NOT NULL,
|
||||||
`publisherId` VARCHAR(191) NULL,
|
`publisherId` VARCHAR(191) NULL,
|
||||||
`shiftId` INTEGER NULL,
|
`shiftId` INTEGER NULL,
|
||||||
`content` VARCHAR(191) NOT NULL,
|
`content` VARCHAR(5000) NOT NULL,
|
||||||
`type` ENUM('AssignmentReplacementRequested', 'AssignmentReplacementAccepted', 'SentEmail') NOT NULL,
|
`type` ENUM('AssignmentReplacementRequested', 'AssignmentReplacementAccepted', 'SentEmail') NOT NULL,
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ model EventLog {
|
|||||||
publisher Publisher? @relation(fields: [publisherId], references: [id])
|
publisher Publisher? @relation(fields: [publisherId], references: [id])
|
||||||
shiftId Int?
|
shiftId Int?
|
||||||
shift Shift? @relation(fields: [shiftId], references: [id])
|
shift Shift? @relation(fields: [shiftId], references: [id])
|
||||||
content String
|
content String @db.VarChar(5000)
|
||||||
type EventLogType
|
type EventLogType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{{!-- за смяна на {{placeName}} за {{dateStr}}! --}}
|
{{!-- за смяна на {{placeName}} за {{dateStr}}! --}}
|
||||||
</h3>
|
</h3>
|
||||||
<p>Здравей {{firstName}},</p>
|
<p>Здравей {{firstName}},</p>
|
||||||
<p>{{prefix}} {{user.firstName}} {{user.lastName}} търси заместник.</p>
|
<p>{{user.prefix}} {{user.firstName}} {{user.lastName}} търси заместник.</p>
|
||||||
{{!-- <p><strong>Shift Details:</strong></p> --}}
|
{{!-- <p><strong>Shift Details:</strong></p> --}}
|
||||||
<p>Дата: {{dateStr}} <br>Час: {{time}}<br>Място: {{placeName}}</p>
|
<p>Дата: {{dateStr}} <br>Час: {{time}}<br>Място: {{placeName}}</p>
|
||||||
<p>С натискането на бутона по-долу можеш да премеш да го заместваш.
|
<p>С натискането на бутона по-долу можеш да премеш да го заместваш.
|
||||||
|
Reference in New Issue
Block a user