Clean up of the email notifications for Post, Post Comment, and Event create and update.

This commit is contained in:
Scott Idem
2026-02-16 13:34:38 -05:00
parent 6c4cdb4ed0
commit fdfba0f752
3 changed files with 130 additions and 89 deletions

View File

@@ -661,17 +661,22 @@
if (!event_obj_create_result) {
console.log('The result was null or false.');
return false;
}
} else {
if (log_lvl) {
console.log(
'event_obj_create_result:',
event_obj_create_result
);
if (log_lvl) {
console.log(
'event_obj_create_result:',
event_obj_create_result
);
}
$idaa_slct.event_id =
event_obj_create_result.event_id;
$idaa_slct.event_obj = event_obj_create_result;
if ($ae_loc.site_cfg_json?.recovery_mtg_send_staff_new_email) {
send_staff_notification_email(event_obj_create_result);
}
}
$idaa_slct.event_id =
event_obj_create_result.event_id;
$idaa_slct.event_obj = event_obj_create_result;
return event_obj_create_result;
})
@@ -685,23 +690,14 @@
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
log_lvl = 1;
if (log_lvl) {
console.log(
`Check if we should send staff update email...`, $ae_loc.site_cfg_json?.recovery_mtg_send_staff_new_email
);
}
if (
// !$ae_loc.administrator_access &&
$ae_loc.site_cfg_json?.recovery_mtg_send_staff_new_email
) {
send_staff_notification_email();
}
// log_lvl = 1;
// if (log_lvl) {
// console.log(
// `Check if we should send staff update email...`, $ae_loc.site_cfg_json?.recovery_mtg_send_staff_new_email
// );
// }
});
// log_lvl = 0;
return prom_api__event_obj;
} else {
prom_api__event_obj = events_func
@@ -715,9 +711,17 @@
if (!event_obj_update_result) {
console.log('The result was null or false.');
return false;
}
} else {
if (log_lvl) {
console.log('event_obj_update_result:', event_obj_update_result);
}
$idaa_slct.event_obj = event_obj_update_result;
$idaa_slct.event_obj = event_obj_update_result;
if ($ae_loc.site_cfg_json?.recovery_mtg_send_staff_update_email) {
send_staff_notification_email(event_obj_update_result);
}
}
return event_obj_update_result;
})
@@ -731,12 +735,12 @@
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
log_lvl = 1;
if (log_lvl) {
console.log(
`Check if we should send staff update email...`, $ae_loc.site_cfg_json?.recovery_mtg_send_staff_update_email
);
}
// log_lvl = 1;
// if (log_lvl) {
// console.log(
// `Check if we should send staff update email...`, $ae_loc.site_cfg_json?.recovery_mtg_send_staff_update_email
// );
// }
// if (
// // !$ae_loc.administrator_access &&
@@ -746,7 +750,7 @@
// send_staff_notification_email();
// }
send_staff_notification_email();
// send_staff_notification_email(event_do);
});
// log_lvl = 0;
@@ -795,11 +799,12 @@
return prom_api__event_obj;
}
// Updated 2025-02-07
function send_staff_notification_email() {
// Updated 2026-02-16
// The event_do (Event (Recovery Meeting) Data Out) should be the new form data
function send_staff_notification_email(event_do: key_val) {
if (log_lvl) {
console.log(
`*** send_staff_notification_email() *** To: ${$ae_loc.site_cfg_json?.admin_email} From: ${$ae_loc.site_cfg_json?.noreply_email} Subject: IDAA Recovery Meeting: ${$idaa_slct.event_obj.name} (ID: ${$idaa_slct.event_id})`
`*** send_staff_notification_email() *** To: ${$ae_loc.site_cfg_json?.admin_email} From: ${$ae_loc.site_cfg_json?.noreply_email} Subject: IDAA Recovery Meeting: ${event_do.name} (ID: ${event_do.event_id})`
);
}
@@ -807,19 +812,19 @@
$ae_loc.site_cfg_json.novi_meetings_base_url ??
`${$ae_loc.url_origin}/idaa/recovery_meetings`;
let subject = `IDAA Recovery Meeting: ${$idaa_slct.event_obj.name} (ID: ${$idaa_slct.event_id})`;
let subject = `IDAA Recovery Meeting: ${event_do.name} (ID: ${event_do.event_id})`;
let body_html = `
<div>
<p>A recovery meeting has been created or updated named "${$idaa_slct.event_obj.name}".</p>
<p>A recovery meeting has been created or updated named "${event_do.name}".</p>
</div>
<br>
<div>
IDAA Recovery Meeting ID: ${$idaa_slct.event_id}<br>
IDAA Recovery Meeting ID: ${event_do.event_id}<br>
<p>Use this link to view the meeting.<br>
Copy and paste link: <a href="${link_base_url}?event_id=${$idaa_slct.event_id}">${link_base_url}?event_id=${$idaa_slct.event_id}</a></p>
Copy and paste link: <a href="${link_base_url}?event_id=${event_do.event_id}">${link_base_url}?event_id=${event_do.event_id}</a></p>
</div>`;
api.send_email({