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.
This commit is contained in:
@@ -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(/ /g, " ")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/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`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user