Prevent editing or forwarding polls

This commit is contained in:
trevor-signal
2025-11-04 11:54:58 -05:00
committed by GitHub
parent 6869245b89
commit 9ee49cbfdc
3 changed files with 16 additions and 3 deletions

View File

@@ -76,3 +76,9 @@ export const shouldTryToCopyFromQuotedMessage = ({
return true; return true;
}; };
export function isPoll(
message: Pick<ReadonlyMessageAttributesType, 'poll'>
): boolean {
return Boolean(message.poll);
}

View File

@@ -137,7 +137,12 @@ import { getConversationColorAttributes } from '../../util/getConversationColorA
import { DAY, DurationInSeconds } from '../../util/durations/index.std.js'; import { DAY, DurationInSeconds } from '../../util/durations/index.std.js';
import { getStoryReplyText } from '../../util/getStoryReplyText.std.js'; import { getStoryReplyText } from '../../util/getStoryReplyText.std.js';
import type { MessageAttributesWithPaymentEvent } from '../../messages/payments.std.js'; import type { MessageAttributesWithPaymentEvent } from '../../messages/payments.std.js';
import { isIncoming, isOutgoing, isStory } from '../../messages/helpers.std.js'; import {
isIncoming,
isOutgoing,
isPoll,
isStory,
} from '../../messages/helpers.std.js';
import { messageHasPaymentEvent } from '../../messages/payments.std.js'; import { messageHasPaymentEvent } from '../../messages/payments.std.js';
import { calculateExpirationTimestamp } from '../../util/expirationTimer.std.js'; import { calculateExpirationTimestamp } from '../../util/expirationTimer.std.js';
@@ -2245,7 +2250,8 @@ export function canForward(message: ReadonlyMessageAttributesType): boolean {
!isTapToView(message) && !isTapToView(message) &&
!message.deletedForEveryone && !message.deletedForEveryone &&
!message.giftBadge && !message.giftBadge &&
!getPayment(message) !getPayment(message) &&
!isPoll(message)
); );
} }

View File

@@ -4,7 +4,7 @@
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts'; import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
import { DAY } from './durations/index.std.js'; import { DAY } from './durations/index.std.js';
import { isMoreRecentThan } from './timestamp.std.js'; import { isMoreRecentThan } from './timestamp.std.js';
import { isOutgoing } from '../messages/helpers.std.js'; import { isOutgoing, isPoll } from '../messages/helpers.std.js';
import { isMessageNoteToSelf } from './isMessageNoteToSelf.dom.js'; import { isMessageNoteToSelf } from './isMessageNoteToSelf.dom.js';
export const MESSAGE_MAX_EDIT_COUNT = 10; export const MESSAGE_MAX_EDIT_COUNT = 10;
@@ -16,6 +16,7 @@ export function canEditMessage(
!message.sms && !message.sms &&
!message.deletedForEveryone && !message.deletedForEveryone &&
isOutgoing(message) && isOutgoing(message) &&
!isPoll(message) &&
(isMoreRecentThan(message.sent_at, DAY) || isMessageNoteToSelf(message)) && (isMoreRecentThan(message.sent_at, DAY) || isMessageNoteToSelf(message)) &&
Boolean(message.body) Boolean(message.body)
); );