Message: Do not display message with spoilers

This commit is contained in:
Alexander Zinchuk 2022-01-07 19:57:15 +01:00
parent 2d3de3feb3
commit 206a24031d
3 changed files with 15 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import {
} from '../../types';
import {
CONTENT_NOT_SUPPORTED,
DELETED_COMMENTS_CHANNEL_ID,
LOCAL_MESSAGE_ID_BASE,
SERVICE_NOTIFICATIONS_USER_ID,
@ -217,6 +218,12 @@ export function buildMessageTextContent(
message: string,
entities?: GramJs.TypeMessageEntity[],
): ApiFormattedText {
if (entities?.some((e) => e instanceof GramJs.MessageEntitySpoiler)) {
return {
text: CONTENT_NOT_SUPPORTED,
};
}
return {
text: message,
...(entities && { entities: entities.map(buildApiMessageEntity) }),

View File

@ -145,6 +145,8 @@ export const CONTENT_TYPES_WITH_PREVIEW = new Set([
...SUPPORTED_VIDEO_CONTENT_TYPES,
]);
export const CONTENT_NOT_SUPPORTED = 'The message is not supported on this version of Telegram.';
// eslint-disable-next-line max-len
export const RE_LINK_TEMPLATE = '((ftp|https?):\\/\\/)?((www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,63})\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)';
export const RE_MENTION_TEMPLATE = '(@[\\w\\d_-]+)';

View File

@ -3,13 +3,17 @@ import {
} from '../../api/types';
import { LangFn } from '../../hooks/useLang';
import { LOCAL_MESSAGE_ID_BASE, SERVICE_NOTIFICATIONS_USER_ID, RE_LINK_TEMPLATE } from '../../config';
import {
LOCAL_MESSAGE_ID_BASE,
SERVICE_NOTIFICATIONS_USER_ID,
RE_LINK_TEMPLATE,
CONTENT_NOT_SUPPORTED,
} from '../../config';
import { getUserFullName } from './users';
import { isWebpSupported, IS_OPUS_SUPPORTED } from '../../util/environment';
import { getChatTitle, isUserId } from './chats';
import parseEmojiOnlyString from '../../components/common/helpers/parseEmojiOnlyString';
const CONTENT_NOT_SUPPORTED = 'The message is not supported on this version of Telegram';
const RE_LINK = new RegExp(RE_LINK_TEMPLATE, 'i');
const TRUNCATED_SUMMARY_LENGTH = 80;