MM-26346: check for nil Message in DisableMentionHighlights (#14972)

Sometimes a PostPatch may not contain the message field. For example,
while pinning a post, only the IsPinned field is set, and everything
else is nil. In that case, DisableMentionHighlights would throw a panic.

We handle that case by checking for nil first.
Этот коммит содержится в:
Agniva De Sarker
2020-07-06 20:29:36 +05:30
коммит произвёл GitHub
родитель af8b914c6c
Коммит 58dc0772bc
2 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@@ -521,6 +521,9 @@ func (o *Post) DisableMentionHighlights() string {
// DisableMentionHighlights disables mention highlighting for a post patch if required.
func (o *PostPatch) DisableMentionHighlights() {
if o.Message == nil {
return
}
if _, hasMentions := findAtChannelMention(*o.Message); hasMentions {
if o.Props == nil {
o.Props = &StringInterface{}