Fix reply/quoting breaking for poll messages

Co-authored-by: yash-signal <yash@signal.org>
This commit is contained in:
automated-signal
2025-10-31 12:29:52 -05:00
committed by GitHub
parent 65d83bdf2e
commit 65617ef479
5 changed files with 35 additions and 9 deletions

View File

@@ -3076,6 +3076,10 @@
"messageformat": "Poll: {pollQuestion}",
"description": "Shown in notifications and in the left pane when a poll message is received. {pollQuestion} is the poll question text."
},
"icu:Poll--preview": {
"messageformat": "Poll: {pollQuestion}",
"description": "Shown in notifications, the left pane message preview, and quotes when a poll message is referenced."
},
"icu:message--getNotificationText--text-with-emoji": {
"messageformat": "{emoji} {text}",
"description": "Shown in notifications and in the left pane when text has an emoji. Probably always [emoji] [text] on LTR languages and [text] [emoji] on RTL languages."

View File

@@ -24,6 +24,7 @@ import { isDownloadable } from '../util/Attachment.std.js';
const { omit } = lodash;
const log = createLogger('copyQuote');
const { i18n } = window.SignalContext;
export type MinimalMessageCache = Readonly<{
findBySentAt(
@@ -129,7 +130,11 @@ export const copyQuoteContentFromOriginal = async (
quote.isViewOnce = false;
// eslint-disable-next-line no-param-reassign
quote.text = getQuoteBodyText(message.attributes, quote.id);
quote.text = getQuoteBodyText({
messageAttributes: message.attributes,
id: quote.id,
i18n,
});
// eslint-disable-next-line no-param-reassign
quote.bodyRanges = message.attributes.bodyRanges;

View File

@@ -514,7 +514,7 @@ export function getNotificationDataForMessage(
if (poll) {
return {
emoji: '📊',
text: i18n('icu:message--getNotificationText--poll', {
text: i18n('icu:Poll--preview', {
pollQuestion: poll.question,
}),
bodyRanges,

View File

@@ -2,12 +2,18 @@
// SPDX-License-Identifier: AGPL-3.0-only
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
import type { LocalizerType } from '../types/Util.std.js';
import * as EmbeddedContact from '../types/EmbeddedContact.std.js';
export function getQuoteBodyText(
messageAttributes: ReadonlyMessageAttributesType,
id: number | null
): string | undefined {
export function getQuoteBodyText({
messageAttributes,
id,
i18n,
}: {
messageAttributes: ReadonlyMessageAttributesType;
id: number | null;
i18n: LocalizerType;
}): string | undefined {
const storyReactionEmoji = messageAttributes.storyReaction?.emoji;
if (id != null) {
@@ -20,11 +26,17 @@ export function getQuoteBodyText(
}
}
const { body, contact: embeddedContact } = messageAttributes;
const { body, contact: embeddedContact, poll } = messageAttributes;
const embeddedContactName =
embeddedContact && embeddedContact.length > 0
? EmbeddedContact.getName(embeddedContact[0])
: '';
return body || embeddedContactName || storyReactionEmoji;
const pollText = poll
? i18n('icu:Poll--preview', {
pollQuestion: poll.question,
})
: undefined;
return body || embeddedContactName || pollText || storyReactionEmoji;
}

View File

@@ -25,6 +25,7 @@ import { getLocalAttachmentUrl } from './getLocalAttachmentUrl.std.js';
import type { QuotedMessageForComposerType } from '../state/ducks/composer.preload.js';
const log = createLogger('makeQuote');
const { i18n } = window.SignalContext;
export async function makeQuote(
quotedMessage: MessageAttributesType
@@ -56,7 +57,11 @@ export async function makeQuote(
isGiftBadge: isGiftBadge(quotedMessage),
messageId,
referencedMessageNotFound: false,
text: getQuoteBodyText(quotedMessage, quoteId),
text: getQuoteBodyText({
messageAttributes: quotedMessage,
id: quoteId,
i18n,
}),
};
}