-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[MM-11442] Strip markdown on desktop notification and "commented on" #1471
Conversation
@esethna May I request first for PM review just to make sure that I'm not missing anything? Thanks! |
@saturninoabril I was trying it out for a customer but wasn't able to get desktop notifications to show a popup.. I hear the sound though |
@jasonblais That's weird... in this test server, it happened to me on Chrome but not on FF... but on local, it works for me. I'll check this out. Thanks! |
@jasonblais I've tested this again and it's happening even on master. I've verified this using the test PR #1476.
I filed a separate ticket to look further into this https://mattermost.atlassian.net/browse/MM-11453. To test this PR, I suggest to use browser other than Chrome for the meantime. |
@@ -194,7 +200,10 @@ export default class PostBody extends React.PureComponent { | |||
className='theme' | |||
onClick={this.props.handleCommentClick} | |||
> | |||
{message} | |||
<Markdown | |||
message={formatWithRenderer(message, new RemoveMarkdown())} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually running the message through the Markdown parser/renderer twice since it's doing it once here and once inside the Markdown component. Maybe we could instead pass the renderer as a prop to the Markdown component and then have it pass it into TextFormatting.formatText
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll address that after QA review. thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @saturninoabril, thanks! Queuing for QA review as there are lots of corner cases and different markdown cases to test
actions/notification_actions.jsx
Outdated
@@ -98,8 +101,10 @@ export function sendDesktopNotification(post, msgProps) { | |||
notifyText = notifyText.substring(0, 49) + '...'; | |||
} | |||
|
|||
const strippedMarkdownNotifyText = formatWithRenderer(notifyText, new RemoveMarkdown()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the RemoveMarkdown
instance is invariant based on the message, can we create a constant for it and not create a new instance every time?
Hey @saturninoabril and @jasonblais , I've tested on the SpinMint and found a few cases where the markdown does not get stripped out of notifications. Please take a look over these and let me know if these cases should also have the markdown stripped out. 1. URLS for links and in-line images do not get stripped out. Such as "[Check out Mattermost!](https://about.mattermost.com/)" or "[![Mattermost](../../images/icon-76x76.png)](https://github.com/mattermost/mattermost-server) " 2. using "-" underline to make headings such as Large Heading ------------- (making headings w\ '#' does get removed) 3. Code block w\ syntax set. (code blocks without syntax get stripped out) ``` go package main import "fmt" func main() { fmt.Println("Hello, 世界") } ``` 4. LaTex formatting is not stripped out. ```latex X_k = \sum_{n=0}^{2N-1} x_n \cos \left[\frac{\pi}{N} \left(n+\frac{1}{2}+\frac{N}{2}\right) \left(k+\frac{1}{2}\right) \right] ``` 5. Table structure characters will not be removed. | Left-Aligned | Center Aligned | Right Aligned | | :------------ |:---------------:| -----:| | Left column 1 | this text | $100 | | Left column 2 | is | $10 | | Left column 3 | centered | $1 | Also, @saturninoabril would you be able to change the mobile push notification for me? Currently, it's set so that notification for mobile do not display any of the text from the post - only the generic message. So, I was unable to check mobile. I seem to recall this is a server setting somewhere but don't know where. |
Thanks @DHaussermann. However, markdown strip for push notification on RN is not included here. This is for desktop only + "commented on" |
Hi @saturninoabril, Thanks, I forgot that RN notifications were not in scope :). Regarding the list above, number 1 with the link text may not be an issue but, it seems to me the rest of the markdown types should be changed to work consistently with the others in notifications. Is this possible? Also looked over the "Commented On" and it looks good. Numbered lists will show numbers and task lists with square brackets will show the formatting but it looks reasonably clean. |
|
Spinmint test server created at: http:https://i-077cc181c323993fc.test.spinmint.com Test Admin Account: Username: Test User Account: Username: Instance ID: i-077cc181c323993fc |
@DHaussermann Thank you for testing. I've updated the push notification which should be fixed now. Please test again, thanks |
@@ -190,12 +199,15 @@ export default class PostBody extends React.PureComponent { | |||
apostrophe, | |||
}} | |||
/> | |||
<a | |||
className='theme' | |||
<span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add role='button'
and tabindex='0'
to this span? That's needed to make the span properly accessible from the keyboard or when using accessibility devices since it's no longer an anchor tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I never thought of that. I'll keep that in mind.
It's now updated, thanks!
@saturninoabril |
Spinmint test server destroyed |
…attermost#1471) * strip markdown on push notification and "commented on" * address dev review comment * strip markdown on push notification * update the span to include role and tabIndex for accessibilty
Summary
Stripped markdown on push notification and "commented on".
On "commented on", it's not specified on the ticket but I let it render with emoji and profile pop-over (can easily remove if not expected)
Ticket Link
Jira ticket: MM-11442
Checklist
make check-style
to check for style errors (required for all pull requests)make test
to ensure unit and component tests passed