Address issues
Этот коммит содержится в:
@@ -131,27 +131,29 @@ func (a *App) getEmbedForPost(post *model.Post, firstLink string) (*model.PostEm
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if firstLink != "" {
|
if firstLink == "" {
|
||||||
og, image, err := a.getLinkMetadata(firstLink, true)
|
return nil, nil
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if og != nil {
|
og, image, err := a.getLinkMetadata(firstLink, true)
|
||||||
return &model.PostEmbed{
|
if err != nil {
|
||||||
Type: model.POST_EMBED_OPENGRAPH,
|
return nil, err
|
||||||
URL: firstLink,
|
}
|
||||||
Data: og,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if image != nil {
|
if og != nil {
|
||||||
// Note that we're not passing the image info here since they'll be part of the PostMetadata.Images field
|
return &model.PostEmbed{
|
||||||
return &model.PostEmbed{
|
Type: model.POST_EMBED_OPENGRAPH,
|
||||||
Type: model.POST_EMBED_IMAGE,
|
URL: firstLink,
|
||||||
URL: firstLink,
|
Data: og,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if image != nil {
|
||||||
|
// Note that we're not passing the image info here since they'll be part of the PostMetadata.Images field
|
||||||
|
return &model.PostEmbed{
|
||||||
|
Type: model.POST_EMBED_IMAGE,
|
||||||
|
URL: firstLink,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ type PostForIndexing struct {
|
|||||||
ParentCreateAt *int64 `json:"parent_create_at"`
|
ParentCreateAt *int64 `json:"parent_create_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shallowly clone the a post
|
// Clone shallowly copies the post.
|
||||||
func (o *Post) Clone() *Post {
|
func (o *Post) Clone() *Post {
|
||||||
copy := *o
|
copy := *o
|
||||||
return ©
|
return ©
|
||||||
|
|||||||
@@ -4,21 +4,23 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type PostMetadata struct {
|
type PostMetadata struct {
|
||||||
// An array of the information required to render additional details about the contents of this post.
|
// Embeds holds information required to render content embedded in the post. This includes the OpenGraph metadata
|
||||||
|
// for links in the post.
|
||||||
Embeds []*PostEmbed `json:"embeds,omitempty"`
|
Embeds []*PostEmbed `json:"embeds,omitempty"`
|
||||||
|
|
||||||
// An arrayof the custom emojis used in the post or in reactions to the post.
|
// Emojis holds all custom emojis used in the post or used in reaction to the post.
|
||||||
Emojis []*Emoji `json:"emojis,omitempty"`
|
Emojis []*Emoji `json:"emojis,omitempty"`
|
||||||
|
|
||||||
// An array of information about the file attachments on the post.
|
// Files holds information about the file attachments on the post.
|
||||||
Files []*FileInfo `json:"files,omitempty"`
|
Files []*FileInfo `json:"files,omitempty"`
|
||||||
|
|
||||||
// A map of image URL to information about all external images in the post. This includes image embeds,
|
// Images holds the dimensions of all external images in the post as a map of the image URL to its diemsnions.
|
||||||
// inline Markdown images, OpenGraph images, and message attachment images, but it does not contain the dimensions
|
// This includes image embeds (when the message contains a plaintext link to an image), Markdown images, images
|
||||||
// of file attachments which are contained in PostMetadata.FileInfos.
|
// contained in the OpenGraph metadata, and images contained in message attachments. It does not contain
|
||||||
|
// the dimensions of any file attachments as those are stored in FileInfos.
|
||||||
Images map[string]*PostImage `json:"images,omitempty"`
|
Images map[string]*PostImage `json:"images,omitempty"`
|
||||||
|
|
||||||
// A list of reactions made to the post
|
// Reactions holds reactions made to the post.
|
||||||
Reactions []*Reaction `json:"reactions,omitempty"`
|
Reactions []*Reaction `json:"reactions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
// be used as part of a SQL query.
|
// be used as part of a SQL query.
|
||||||
func MapStringsToQueryParams(list []string, paramPrefix string) (string, map[string]interface{}) {
|
func MapStringsToQueryParams(list []string, paramPrefix string) (string, map[string]interface{}) {
|
||||||
keys := bytes.Buffer{}
|
keys := bytes.Buffer{}
|
||||||
params := make(map[string]interface{})
|
params := make(map[string]interface{}, len(list))
|
||||||
for i, entry := range list {
|
for i, entry := range list {
|
||||||
if keys.Len() > 0 {
|
if keys.Len() > 0 {
|
||||||
keys.WriteString(",")
|
keys.WriteString(",")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user