коммит произвёл
Joram Wilander
родитель
838bb8cee2
Коммит
23be0167f4
13
app/post.go
13
app/post.go
@@ -6,6 +6,7 @@ package app
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"time"
|
||||||
|
|
||||||
l4g "github.com/alecthomas/log4go"
|
l4g "github.com/alecthomas/log4go"
|
||||||
"github.com/dyatlov/go-opengraph/opengraph"
|
"github.com/dyatlov/go-opengraph/opengraph"
|
||||||
@@ -15,6 +16,14 @@ import (
|
|||||||
"github.com/mattermost/platform/utils"
|
"github.com/mattermost/platform/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
c = &http.Client{
|
||||||
|
Timeout: 5 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
linkWithTextRegex = regexp.MustCompile(`<([^<\|]+)\|([^>]+)>`)
|
||||||
|
)
|
||||||
|
|
||||||
func CreatePostAsUser(post *model.Post) (*model.Post, *model.AppError) {
|
func CreatePostAsUser(post *model.Post) (*model.Post, *model.AppError) {
|
||||||
// Check that channel has not been deleted
|
// Check that channel has not been deleted
|
||||||
var channel *model.Channel
|
var channel *model.Channel
|
||||||
@@ -169,8 +178,6 @@ func handlePostEvents(post *model.Post, teamId string, triggerWebhooks bool) *mo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var linkWithTextRegex *regexp.Regexp = regexp.MustCompile(`<([^<\|]+)\|([^>]+)>`)
|
|
||||||
|
|
||||||
// This method only parses and processes the attachments,
|
// This method only parses and processes the attachments,
|
||||||
// all else should be set in the post which is passed
|
// all else should be set in the post which is passed
|
||||||
func parseSlackAttachment(post *model.Post, attachments interface{}) {
|
func parseSlackAttachment(post *model.Post, attachments interface{}) {
|
||||||
@@ -497,7 +504,7 @@ func GetFileInfosForPost(postId string, readFromMaster bool) ([]*model.FileInfo,
|
|||||||
func GetOpenGraphMetadata(url string) *opengraph.OpenGraph {
|
func GetOpenGraphMetadata(url string) *opengraph.OpenGraph {
|
||||||
og := opengraph.NewOpenGraph()
|
og := opengraph.NewOpenGraph()
|
||||||
|
|
||||||
res, err := http.Get(url)
|
res, err := c.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return og
|
return og
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user