MM-45208: strip post meta for plugins (#20686)
Try two...
* Revert "Revert "Removed the opengraph type dependency for plugins by stripping post Metadata (#20612)" (#20684)"
This reverts commit 32dee6d449.
* Fixed race condition
* PR feedback
* lint
Этот коммит содержится в:
@@ -736,18 +736,10 @@ func (o *Post) ToNilIfInvalid() *Post {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Post) RemovePreviewPost() {
|
||||
if o.Metadata == nil || o.Metadata.Embeds == nil {
|
||||
return
|
||||
}
|
||||
n := 0
|
||||
for _, embed := range o.Metadata.Embeds {
|
||||
if embed.Type != PostEmbedPermalink {
|
||||
o.Metadata.Embeds[n] = embed
|
||||
n++
|
||||
}
|
||||
}
|
||||
o.Metadata.Embeds = o.Metadata.Embeds[:n]
|
||||
func (o *Post) ForPlugin() *Post {
|
||||
p := o.Clone()
|
||||
p.Metadata = nil
|
||||
return p
|
||||
}
|
||||
|
||||
func (o *Post) GetPreviewPost() *PreviewPost {
|
||||
|
||||
@@ -46,6 +46,14 @@ func (o *PostList) Clone() *PostList {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *PostList) ForPlugin() *PostList {
|
||||
copy := o.Clone()
|
||||
for k, p := range copy.Posts {
|
||||
copy.Posts[k] = p.ForPlugin()
|
||||
}
|
||||
return copy
|
||||
}
|
||||
|
||||
func (o *PostList) ToSlice() []*Post {
|
||||
var posts []*Post
|
||||
|
||||
|
||||
@@ -33,3 +33,9 @@ func (o *PostSearchResults) EncodeJSON(w io.Writer) error {
|
||||
o.PostList.StripActionIntegrations()
|
||||
return json.NewEncoder(w).Encode(o)
|
||||
}
|
||||
|
||||
func (o *PostSearchResults) ForPlugin() *PostSearchResults {
|
||||
copy := *o
|
||||
copy.PostList = copy.PostList.ForPlugin()
|
||||
return ©
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user