Skip to content

Commit

Permalink
improve TBA notification
Browse files Browse the repository at this point in the history
  • Loading branch information
c2d13p committed Nov 6, 2024
1 parent 495f242 commit c88ccb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/controllers/processes/visits.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ async function notifyVisit(visit_id, message) {
let text = message || ''

text +=`
Entrata su DM Manager: ${config.BASE_URL}/process/visits/${visit_id}
Link visita su DM Manager: ${config.BASE_URL}/process/visits/${visit_id}
${visit.referencePeople.map(p => `Referente: ${p.firstName} ${p.lastName} <${p.email}>`).join('\n')}
Visitatore/trice: ${person.firstName} ${person.lastName}
Affiliazione/i: ${affiliations}
Expand Down
8 changes: 5 additions & 3 deletions server/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ async function notificaTBA() {

if (visits.length > 0) {
const visitsList = visits.map(visit => {
const daysUntilVisit = Math.round((visit.startDate - today) / (1000 * 60 * 60 * 24))
const daysUntilVisit = Math.floor((visit.startDate - today) / (1000 * 60 * 60 * 24))

let text = daysUntilVisit === 1
? `Visita tra ${daysUntilVisit} giorno:\n`
Expand All @@ -408,6 +408,7 @@ async function notificaTBA() {
`${ref.firstName} ${ref.lastName} (${ref.email || 'no email'})`
).join(", ")
text += `Referenti: ${references}\n`
text += `Link visita su DM Manager: ${config.BASE_URL}/process/visits/${visit._id}\n`

return text
}).join("\n\n")
Expand All @@ -423,8 +424,8 @@ ${visitsList}\n\n`
const daysUntilSeminar = Math.round((seminar.startDatetime - today) / (1000 * 60 * 60 * 24))

let text = daysUntilSeminar === 1
? `Seminario tra ${daysUntilSeminar} giorno:\n`
: `Seminario tra ${daysUntilSeminar} giorni:\n`;
? `Seminario tra ${daysUntilSeminar} giorno\n`
: `Seminario tra ${daysUntilSeminar} giorni\n`;

const speakers = seminar.speakers.map(speaker => {
const affiliation = speaker.affiliations.map(a => a.name).join(", ")
Expand All @@ -438,6 +439,7 @@ ${visitsList}\n\n`
`${org.firstName} ${org.lastName} (${org.email || 'no email'})`
).join(", ")
text += `Organizzatori: ${organizers}\n`
text += `Link seminario su DM Manager: ${config.BASE_URL}/process/seminars/add/${seminar._id}\n`

return text
}).join("\n\n")
Expand Down

0 comments on commit c88ccb1

Please sign in to comment.