Use singular “update” when the digest has one item so FCM and SMS bodies stay grammatical.
This commit is contained in:
@@ -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(
|
||||||
|
|||||||
@@ -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.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user