mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-21 05:54:10 +08:00
Avoid setting an empty value on slash command IconURL (#36327)
* Avoid setting an empty value on slash command IconURL When `PostEnablePostIconOverride` is enabled and no icon URL is provided, the override icon URL was being set to empty and triggering a warning. This change updates the behavior not to set the icon at all, avoiding the triggering of the warn message while keeping the behavior. * Adds an additional check to the test --------- Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
This commit is contained in:
co-authored by
Miguel de la Cruz
parent
b0b9f2ee84
commit
797c737421
@@ -672,8 +672,6 @@ func (a *App) HandleCommandResponsePost(rctx request.CTX, command *model.Command
|
||||
} else if response.IconURL != "" {
|
||||
post.AddProp(model.PostPropsOverrideIconURL, response.IconURL)
|
||||
isBotPost = true
|
||||
} else {
|
||||
post.AddProp(model.PostPropsOverrideIconURL, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,6 +250,17 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
||||
assert.Equal(t, resp.IconURL, post.GetProp(model.PostPropsOverrideIconURL))
|
||||
assert.Equal(t, "true", post.GetProp(model.PostPropsFromWebhook))
|
||||
|
||||
resp.IconURL = ""
|
||||
|
||||
// When both command and response icon URLs are empty and EnablePostIconOverride is enabled,
|
||||
// override_icon_url must not be set (avoids spurious "prop must be a valid URL" warning).
|
||||
post, err = th.App.HandleCommandResponsePost(th.Context, command, args, resp, builtIn)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, post.GetProp(model.PostPropsOverrideIconURL))
|
||||
assert.NotContains(t, post.GetProps(), model.PostPropsOverrideIconURL)
|
||||
|
||||
resp.IconURL = "Response icon url"
|
||||
|
||||
// Test Slack text conversion.
|
||||
resp.Text = "<!channel>"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user