[MM-45272] Fix MM-45272 (#24701)
* Fix MM-45272 * Properly handle permalinks * Fix * Fix tests * Handle only not found case for team member * Fix lint * Use proper config value * Separate permission in several statements * Add tests * Fix lint * Revert changes on utils * Address feedback and more fixes * Address feedback * Fix test * Fix test and related bug * Fix and reorder test * Address feedback * Address feedback --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c395ec6245
Коммит
2ff0fe343e
@@ -196,7 +196,19 @@ func (a *App) sanitizePostMetadataForUserAndChannel(c request.CTX, post *model.P
|
||||
}
|
||||
|
||||
if previewedChannel != nil && !a.HasPermissionToReadChannel(c, userID, previewedChannel) {
|
||||
post.Metadata.Embeds[0].Data = nil
|
||||
// Remove all permalink embeds and only keep non-permalink embeds.
|
||||
// We always have only one permalink embed even if the post
|
||||
// contains multiple permalinks.
|
||||
var newEmbeds []*model.PostEmbed
|
||||
for _, embed := range post.Metadata.Embeds {
|
||||
if embed.Type != model.PostEmbedPermalink {
|
||||
newEmbeds = append(newEmbeds, embed)
|
||||
}
|
||||
}
|
||||
|
||||
post.Metadata.Embeds = newEmbeds
|
||||
|
||||
post.DelProp(model.PostPropsPreviewedPost)
|
||||
}
|
||||
|
||||
return post
|
||||
@@ -229,6 +241,8 @@ func (a *App) SanitizePostMetadataForUser(c request.CTX, post *model.Post, userI
|
||||
}
|
||||
|
||||
post.Metadata.Embeds = newEmbeds
|
||||
|
||||
post.DelProp(model.PostPropsPreviewedPost)
|
||||
}
|
||||
|
||||
return post, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user