Sort of bug fix and improvements for IDAA BB notifications and loading a post based on the URL param.

This commit is contained in:
Scott Idem
2025-01-28 11:51:27 -05:00
parent db6b481983
commit c62507d484
8 changed files with 71 additions and 12 deletions

View File

@@ -31,6 +31,10 @@ let idaa_local_data_struct: key_val = {
"58db22ee-4b0a-49a7-9f34-53d2ba85a84b",
],
novi_archives_base_url: "https://www.idaa.org/idaa-archives",
novi_bb_base_url: "https://www.idaa.org/idaa-bulletin-board",
novi_meetings_base_url: "https://www.idaa.org/idaa-meetings",
'ds': {},
'idaa_cfg_json': {},
@@ -158,6 +162,7 @@ let idaa_trig_template: key_val = {
archive_id: false,
archive_content_li: false,
event_id: false,
post_id: false,
};
export let idaa_trig: any = writable(idaa_trig_template);
// console.log(`AE IDAA Stores - IDAA Trigger:`, idaa_trig);
@@ -170,6 +175,7 @@ let idaa_prom_template: key_val = {
archive_id: false,
archive_content_li: false,
event_id: false,
post_id: false,
};
export let idaa_prom: any = writable(idaa_prom_template);
// console.log(`AE IDAA Stores - IDAA Trigger:`, idaa_prom);

View File

@@ -41,9 +41,9 @@ export async function load_ae_obj_id__post(
ae_promises.load__post_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post',
obj_id: post_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
obj_id: post_id,
use_alt_table: true,
use_alt_base: false,
params: params,
log_lvl: log_lvl
})
@@ -71,7 +71,7 @@ export async function load_ae_obj_id__post(
console.log('ae_promises.load__post_obj:', ae_promises.load__post_obj);
}
if (inc_comment_li) {
if (inc_comment_li && ae_promises.load__post_obj) {
// Load the comments for the post
if (log_lvl) {
console.log(`Need to load the comment list for the post now`);

View File

@@ -37,9 +37,9 @@ export async function load_ae_obj_id__post_comment(
ae_promises.load__post_comment_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
obj_id: post_comment_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
obj_id: post_comment_id,
use_alt_table: false,
use_alt_base: false,
params: params,
log_lvl: log_lvl
})

View File

@@ -3,6 +3,7 @@ console.log(`IDAA BB - [account_id] +layout.ts start`);
import { error } from '@sveltejs/kit';
import { browser } from '$app/environment';
// import { page } from '$app/state';
import { posts_func } from '$lib/ae_posts/ae_posts_functions';
export async function load({ params, parent }) { // route
@@ -24,6 +25,21 @@ export async function load({ params, parent }) { // route
ae_acct.slct.account_id = account_id;
// let post_id = params.post_id;
// let post_id = page.url.searchParams.has('post_id') ?? null;
// let post_id = page.url.searchParams.get('post_id') ?? null;
// if (!post_id) {
// console.log(`ae Posts - [post_id] +page.ts: The post_id was not found in the params.post_id!!!`);
// // error(404, {
// // message: 'Post ID not found'
// // });
// } else {
// console.log(`ae Posts - [post_id] +page.ts: post_id = `, post_id);
// ae_acct.slct.post_id = post_id;
// }
// ae_acct.slct.post_id = post_id;
if (browser) {
let load_post_obj_li = posts_func.load_ae_obj_li__post({
api_cfg: ae_acct.api,

View File

@@ -25,6 +25,18 @@ import Comp__post_obj_id_view from './ae_idaa_comp__post_obj_id_view.svelte';
import Comp__post_options from './ae_idaa_comp__post_options.svelte';
import { page } from '$app/state';
let post_id = page.url.searchParams.get('post_id') ?? null;
if (!post_id) {
$idaa_slct.post_id = null;
} else {
console.log(`ae Posts - [post_id] +page.ts: post_id = `, post_id);
$idaa_slct.post_id = post_id;
$idaa_trig.post_id = post_id;
}
$: lq__post_obj_li = liveQuery(async () => {
let results = await db_posts.post
.where('account_id')
@@ -103,6 +115,7 @@ $: if ($idaa_trig.post_li) {
}
$: if ($idaa_trig.post_id) {
// log_lvl = 1;
$idaa_trig.post_id = false;
if (log_lvl) {
@@ -119,6 +132,20 @@ $: if ($idaa_trig.post_id) {
try_cache: true,
log_lvl: log_lvl,
});
$idaa_slct.post_obj = $idaa_prom.load__post_obj;
if (!page.url.searchParams.get('post_id')) {
const url = new URL(location);
url.searchParams.set('post_id', $idaa_slct.post_id);
history.pushState({}, '', url);
let message = {'post_id': $idaa_slct.post_id};
window.parent.postMessage(message, "*");
}
$idaa_sess.bb.show__modal_view__post_id = $idaa_slct.post_id;
$idaa_sess.bb.show__modal_edit__post_id = false;
}
</script>

View File

@@ -220,6 +220,8 @@ function send_staff_notification_email() {
console.log(`*** send_staff_notification_email() *** Post ID: ${$idaa_slct.post_id}`);
}
let link_base_url = $ae_loc.site_cfg_json.novi_bb_base_url ?? `${$ae_loc.url_origin}/idaa/bb`;
let subject = `IDAA BB Post Comment on: ${$idaa_slct.post_obj.title ?? '-- not set --'} (ID: ${$idaa_slct.post_id})`;
let body_html = `
@@ -244,7 +246,7 @@ function send_staff_notification_email() {
<div>
IDAA BB Post ID: ${$idaa_slct.post_id}<br>
<p>Use this link to view the post.<br>
Copy and paste link: <a href="${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}">${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}</a></p>
Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${link_base_url}?post_id=${$idaa_slct.post_id}</a></p>
</div>`;
api.send_email({
@@ -263,6 +265,8 @@ function send_poster_notification_email() {
console.log(`*** send_poster_notification_email() *** Post ID: ${$idaa_slct.post_id}`);
}
let link_base_url = $ae_loc.site_cfg_json.novi_bb_base_url ?? `${$ae_loc.url_origin}/idaa/bb`;
let subject = `IDAA BB Post Comment on: ${$idaa_slct.post_obj.title ?? '-- not set --'} (ID: ${$idaa_slct.post_id})`;
let body_html = `
@@ -275,7 +279,7 @@ function send_poster_notification_email() {
<div>
IDAA BB Post ID: ${$idaa_slct.post_id}<br>
<p>Use this link to view the post.<br>
Copy and paste link: <a href="${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}">${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}</a></p>
Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${link_base_url}?post_id=${$idaa_slct.post_id}</a></p>
</div>`;
api.send_email({

View File

@@ -110,6 +110,8 @@ async function handle_submit_form(event: any) {
console.log(post_do);
log_lvl = 1;
if (!$idaa_slct.post_id) {
prom_api__post_obj = posts_func.create_ae_obj__post({
api_cfg: $ae_api,
@@ -270,6 +272,8 @@ function send_staff_notification_email() {
console.log(`*** send_staff_notification_email() *** Post ID: ${$idaa_slct.post_id}`);
}
let link_base_url = $ae_loc.site_cfg_json.novi_bb_base_url ?? `${$ae_loc.url_origin}/idaa/bb`;
let subject = `IDAA BB Post: ${$idaa_slct.post_obj.title} (ID: ${$idaa_slct.post_id})`;
let body_html = `
@@ -288,14 +292,16 @@ function send_staff_notification_email() {
<div>
IDAA BB Post ID: ${$idaa_slct.post_id}<br>
<p>Use this link to view the post.<br>
Copy and paste link: <a href="${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}">${$ae_loc.url_origin}/idaa/bb?post_id=${$idaa_slct.post_id}</a></p>
Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${link_base_url}?post_id=${$idaa_slct.post_id}</a></p>
</div>`;
api.send_email({
api_cfg: $ae_api,
from_email: $ae_loc.site_cfg_json?.noreply_email ?? 'noreply+idaabb@oneskyit.com',
// from_email: 'noreply+idaabb@oneskyit.com',
from_name: $ae_loc.site_cfg_json?.noreply_name ?? 'IDAA BB NoReply',
to_email: $ae_loc.site_cfg_json?.admin_email ?? 'admin+bbpost@oneskyit.com', // 'scott+idaabb@oneskyit.com'
to_email: $ae_loc.site_cfg_json?.admin_email ?? 'admin+bbpost@oneskyit.com',
// to_email: 'test+idaabb@oneskyit.com', // 'scott+idaabb@oneskyit.com'
to_name: $ae_loc.site_cfg_json?.admin_name ?? 'IDAA BB Admin',
subject: subject,
body_html: body_html,

View File

@@ -52,7 +52,7 @@ fetch(novi_api_get_customer_endpoint, requestOptions)
let idaa_ae_iframe_element = document.getElementById('ae_idaa_bb_iframe');
if (idaa_ae_slct_post_id) {
// console.log(`Loading AE Post ID: ${idaa_ae_slct_post_id}`);
console.log(`Loading AE Post ID: ${idaa_ae_slct_post_id}`);
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&post_id=${idaa_ae_slct_post_id}&iframe=true&key=${idaa_osit_site_key}`;
} else {
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&iframe=true&key=${idaa_osit_site_key}`;