diff --git a/lib/shared/messages/join-thread-message-spec.js b/lib/shared/messages/join-thread-message-spec.js --- a/lib/shared/messages/join-thread-message-spec.js +++ b/lib/shared/messages/join-thread-message-spec.js @@ -15,11 +15,13 @@ import type { NotifTexts } from '../../types/notif-types'; import type { ThreadInfo } from '../../types/thread-types'; import type { RelativeUserInfo } from '../../types/user-types'; -import { ET, type EntityText } from '../../utils/entity-text'; +import { + ET, + type EntityText, + pluralizeEntityText, +} from '../../utils/entity-text'; import { values } from '../../utils/objects'; -import { pluralize } from '../../utils/text-utils'; -import { stringForUser } from '../user-utils'; -import type { MessageSpec, NotificationTextsParams } from './message-spec'; +import type { MessageSpec } from './message-spec'; import { joinResult } from './utils'; export const joinThreadMessageSpec: MessageSpec< @@ -82,7 +84,6 @@ async notificationTexts( messageInfos: $ReadOnlyArray, threadInfo: ThreadInfo, - params: NotificationTextsParams, ): Promise { const joinerArray = {}; for (const messageInfo of messageInfos) { @@ -93,10 +94,14 @@ joinerArray[messageInfo.creator.id] = messageInfo.creator; } const joiners = values(joinerArray); - const joinersString = pluralize(joiners.map(stringForUser)); + const joiningUsers = pluralizeEntityText( + joiners.map(user => ET`${ET.user({ userInfo: user })}`), + ); + + const body = ET`${joiningUsers} joined`; + const thread = ET.thread({ display: 'shortName', threadInfo }); + const merged = ET`${body} ${thread}`; - const body = `${joinersString} joined`; - const merged = `${body} ${params.notifThreadName(threadInfo)}`; return { merged, title: threadInfo.uiName, diff --git a/lib/shared/messages/leave-thread-message-spec.js b/lib/shared/messages/leave-thread-message-spec.js --- a/lib/shared/messages/leave-thread-message-spec.js +++ b/lib/shared/messages/leave-thread-message-spec.js @@ -15,11 +15,13 @@ import type { NotifTexts } from '../../types/notif-types'; import type { ThreadInfo } from '../../types/thread-types'; import type { RelativeUserInfo } from '../../types/user-types'; -import { ET, type EntityText } from '../../utils/entity-text'; +import { + ET, + type EntityText, + pluralizeEntityText, +} from '../../utils/entity-text'; import { values } from '../../utils/objects'; -import { pluralize } from '../../utils/text-utils'; -import { stringForUser } from '../user-utils'; -import type { MessageSpec, NotificationTextsParams } from './message-spec'; +import type { MessageSpec } from './message-spec'; import { joinResult } from './utils'; export const leaveThreadMessageSpec: MessageSpec< @@ -82,7 +84,6 @@ async notificationTexts( messageInfos: $ReadOnlyArray, threadInfo: ThreadInfo, - params: NotificationTextsParams, ): Promise { const leaverBeavers = {}; for (const messageInfo of messageInfos) { @@ -93,10 +94,14 @@ leaverBeavers[messageInfo.creator.id] = messageInfo.creator; } const leavers = values(leaverBeavers); - const leaversString = pluralize(leavers.map(stringForUser)); + const leavingUsers = pluralizeEntityText( + leavers.map(user => ET`${ET.user({ userInfo: user })}`), + ); + + const body = ET`${leavingUsers} left`; + const thread = ET.thread({ display: 'shortName', threadInfo }); + const merged = ET`${body} ${thread}`; - const body = `${leaversString} left`; - const merged = `${body} ${params.notifThreadName(threadInfo)}`; return { merged, title: threadInfo.uiName,