diff --git a/model/post.go b/model/post.go index 817ca08a72..852a504f9c 100644 --- a/model/post.go +++ b/model/post.go @@ -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{} diff --git a/model/post_test.go b/model/post_test.go index 09ff0d9d5d..0c38389246 100644 --- a/model/post_test.go +++ b/model/post_test.go @@ -848,4 +848,11 @@ func TestPostPatchDisableMentionHighlights(t *testing.T) { patch.Props = nil }) } + + t.Run("TestNilMessage", func(t *testing.T) { + patch.Message = nil + patch.DisableMentionHighlights() + // Useless assertion to prevent compiler elision. + assert.Nil(t, patch.Message) + }) }