Remove HTML from meeting notification subjects

Strip HTML tags from meeting subjects using a helper function in `executive-meeting-scheduler.ts` to ensure plain text display in push notifications.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: ec660c7b-c476-4440-8578-eef124542d3b
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/IO8TMSC
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
riyadhafraa
2026-05-20 11:16:31 +00:00
parent 388ef108c2
commit 47f31730f7
@@ -20,6 +20,29 @@ function pad2(n: number): string {
return String(n).padStart(2, "0");
}
/**
* Reduce a rich-text snippet (Tiptap HTML) to plain text safe for a
* push-notification body. Meeting titles are stored as rich text so the
* scheduler can't just shove them into the payload — iOS shows the raw
* `<p style="text-align:center">…</p>` markup verbatim on the lock
* screen otherwise.
*/
function stripHtmlToPlainText(input: string | null | undefined): string {
if (!input) return "";
// Drop tags, collapse whitespace, decode the handful of named
// entities Tiptap emits. Anything more (full HTML parser) would
// pull a dependency for zero benefit on a 1-line notification.
const noTags = input.replace(/<[^>]*>/g, " ");
const decoded = noTags
.replace(/&nbsp;/g, " ")
.replace(/&amp;/g, "&")
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&quot;/g, '"')
.replace(/&#39;/g, "'");
return decoded.replace(/\s+/g, " ").trim();
}
function dateKey(d: Date): string {
return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
}
@@ -125,8 +148,14 @@ async function tickOnce(): Promise<void> {
const titleAr = "تذكير اجتماع";
const titleEn = "Meeting reminder";
const subjectAr = meeting.titleAr || meeting.titleEn || "اجتماع";
const subjectEn = meeting.titleEn || meeting.titleAr || "Meeting";
const subjectAr =
stripHtmlToPlainText(meeting.titleAr) ||
stripHtmlToPlainText(meeting.titleEn) ||
"اجتماع";
const subjectEn =
stripHtmlToPlainText(meeting.titleEn) ||
stripHtmlToPlainText(meeting.titleAr) ||
"Meeting";
const bodyAr = `${subjectAr} يبدأ خلال ${deltaMin} دقيقة`;
const bodyEn = `${subjectEn} starts in ${deltaMin} min`;