Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3401621
D5793.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5793.diff
View Options
diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js
--- a/lib/shared/markdown.js
+++ b/lib/shared/markdown.js
@@ -251,6 +251,11 @@
}
const spoilerRegex: RegExp = /^\|\|([^\n]+?)\|\|/g;
+const replaceSpoilerRegex: RegExp = /\|\|(.+?)\|\|/g;
+const spoilerReplacement: string = '⬛⬛⬛';
+
+const stripSpoilersFromNotifications = (text: string): string =>
+ text.replace(replaceSpoilerRegex, spoilerReplacement);
export {
paragraphRegex,
@@ -272,4 +277,5 @@
matchList,
parseList,
matchMentions,
+ stripSpoilersFromNotifications,
};
diff --git a/lib/shared/messages/text-message-spec.js b/lib/shared/messages/text-message-spec.js
--- a/lib/shared/messages/text-message-spec.js
+++ b/lib/shared/messages/text-message-spec.js
@@ -16,7 +16,11 @@
import type { NotifTexts } from '../../types/notif-types';
import type { ThreadInfo } from '../../types/thread-types';
import type { RelativeUserInfo } from '../../types/user-types';
-import { type ASTNode, type SingleASTNode } from '../markdown';
+import {
+ type ASTNode,
+ type SingleASTNode,
+ stripSpoilersFromNotifications,
+} from '../markdown';
import { threadIsGroupChat } from '../thread-utils';
import { stringForUser } from '../user-utils';
import type {
@@ -168,18 +172,21 @@
messageInfo.type === messageTypes.TEXT,
'messageInfo should be messageTypes.TEXT!',
);
+ const notificationTextWithoutSpoilers = stripSpoilersFromNotifications(
+ messageInfo.text,
+ );
if (!threadInfo.name && !threadIsGroupChat(threadInfo)) {
return {
- merged: `${threadInfo.uiName}: ${messageInfo.text}`,
- body: messageInfo.text,
+ merged: `${threadInfo.uiName}: ${notificationTextWithoutSpoilers}`,
+ body: notificationTextWithoutSpoilers,
title: threadInfo.uiName,
};
} else {
const userString = stringForUser(messageInfo.creator);
const threadName = params.notifThreadName(threadInfo);
return {
- merged: `${userString} to ${threadName}: ${messageInfo.text}`,
- body: messageInfo.text,
+ merged: `${userString} to ${threadName}: ${notificationTextWithoutSpoilers}`,
+ body: notificationTextWithoutSpoilers,
title: threadInfo.uiName,
prefix: `${userString}:`,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 1:03 PM (21 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611761
Default Alt Text
D5793.diff (2 KB)
Attached To
Mode
D5793: [lib] Prevent spoiler text from appearing in notifications
Attached
Detach File
Event Timeline
Log In to Comment