Skip to content

Commit

Permalink
MM-62085: Handle nil post priority (mattermost#29496)
Browse files Browse the repository at this point in the history
  • Loading branch information
agnivade authored Dec 6, 2024
1 parent b034092 commit e6c0ed4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/public/model/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,10 @@ func (o *Post) IsUrgent() bool {
return false
}

if postPriority.Priority == nil {
return false
}

return *postPriority.Priority == PostPriorityUrgent
}

Expand Down
13 changes: 13 additions & 0 deletions server/public/model/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,3 +977,16 @@ func TestPostForPlugin(t *testing.T) {
require.NotNil(t, pluginPost.GetProp("requested_features"))
})
}

func TestPostPriority(t *testing.T) {
p := &Post{
Metadata: &PostMetadata{},
}
require.False(t, p.IsUrgent())

p.Metadata.Priority = &PostPriority{}
require.False(t, p.IsUrgent())

p.Metadata.Priority.Priority = NewPointer(PostPriorityUrgent)
require.True(t, p.IsUrgent())
}

0 comments on commit e6c0ed4

Please sign in to comment.