Use singular “update” when the digest has one item so FCM and SMS bodies stay grammatical.

This commit is contained in:
Jose Olarte III
2026-09-18 16:54:09 +08:00
parent 77df676d6e
commit c75060a7f1
4 changed files with 9 additions and 3 deletions
+2 -1
View File
@@ -29,7 +29,8 @@ export type AlertSearchNotifyResult = {
}; };
export function alertSearchNotificationBody(totalCount: number): string { export function alertSearchNotificationBody(totalCount: number): string {
return `You have ${totalCount} new updates.`; const noun = totalCount === 1 ? "update" : "updates";
return `You have ${totalCount} new ${noun}.`;
} }
export function buildAlertSearchNotificationContent( export function buildAlertSearchNotificationContent(
+2 -1
View File
@@ -46,8 +46,9 @@ export type AlertSearchSmsNotifyResult = {
}; };
export function alertSearchSmsBody(totalCount: number): string { export function alertSearchSmsBody(totalCount: number): string {
const noun = totalCount === 1 ? "update" : "updates";
return ( return (
`Gift Economies: you have ${totalCount} new updates. ` + `Gift Economies: you have ${totalCount} new ${noun}. ` +
`${ALERT_SEARCH_SMS_LINK} Reply STOP to end.` `${ALERT_SEARCH_SMS_LINK} Reply STOP to end.`
); );
} }
+1 -1
View File
@@ -151,7 +151,7 @@ describe("alertSearch notification gate", () => {
assert.equal(content.type, ALERT_SEARCH_FCM_TYPE); assert.equal(content.type, ALERT_SEARCH_FCM_TYPE);
assert.equal(content.body.includes(USER), false); assert.equal(content.body.includes(USER), false);
assert.equal(content.body.includes("01H"), false); assert.equal(content.body.includes("01H"), false);
assert.equal(alertSearchNotificationBody(1), "You have 1 new updates."); assert.equal(alertSearchNotificationBody(1), "You have 1 new update.");
}); });
}); });
+4
View File
@@ -124,6 +124,10 @@ describe("alertSearchSmsBody", () => {
assert.ok( assert.ok(
alertSearchSmsBody(999999).length <= SMS_SINGLE_SEGMENT_LIMIT alertSearchSmsBody(999999).length <= SMS_SINGLE_SEGMENT_LIMIT
); );
assert.equal(
alertSearchSmsBody(1),
`Gift Economies: you have 1 new update. ${ALERT_SEARCH_SMS_LINK} Reply STOP to end.`
);
assert.equal(body.includes("giftopia.tech"), false); assert.equal(body.includes("giftopia.tech"), false);
}); });
}); });