[MM-16389] Add icon_emoji parameter to webhooks (#11586)
[MM-16389] Add icon_emoji field to posts from incoming webhooks To be used to substitute the profile picture on posts.
Этот коммит содержится в:
@@ -55,12 +55,37 @@ func (a *App) PreparePostListForClient(originalList *model.PostList) *model.Post
|
||||
return list
|
||||
}
|
||||
|
||||
// OverrideIconURLIfEmoji changes the post icon override URL prop, if it has an emoji icon,
|
||||
// so that it points to the URL (relative) of the emoji - static if emoji is default, /api if custom.
|
||||
func (a *App) OverrideIconURLIfEmoji(post *model.Post) {
|
||||
prop, ok := post.Props[model.POST_PROPS_OVERRIDE_ICON_EMOJI]
|
||||
if !ok || prop == nil {
|
||||
return
|
||||
}
|
||||
emojiName := prop.(string)
|
||||
delete(post.Props, model.POST_PROPS_OVERRIDE_ICON_EMOJI)
|
||||
|
||||
if !*a.Config().ServiceSettings.EnablePostIconOverride || emojiName == "" {
|
||||
return
|
||||
}
|
||||
|
||||
if emojiUrl, err := a.GetEmojiStaticUrl(emojiName); err == nil {
|
||||
post.AddProp(model.POST_PROPS_OVERRIDE_ICON_URL, emojiUrl)
|
||||
} else {
|
||||
mlog.Warn("Failed to retrieve URL for overriden profile icon (emoji)", mlog.String("emojiName", emojiName), mlog.Err(err))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (a *App) PreparePostForClient(originalPost *model.Post, isNewPost bool, isEditPost bool) *model.Post {
|
||||
post := originalPost.Clone()
|
||||
|
||||
// Proxy image links before constructing metadata so that requests go through the proxy
|
||||
post = a.PostWithProxyAddedToImageURLs(post)
|
||||
|
||||
a.OverrideIconURLIfEmoji(post)
|
||||
|
||||
post.Metadata = &model.PostMetadata{}
|
||||
|
||||
// Emojis and reaction counts
|
||||
|
||||
Ссылка в новой задаче
Block a user