summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/post.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/post.go b/app/post.go
index 9ba119413..a41da6c90 100644
--- a/app/post.go
+++ b/app/post.go
@@ -6,6 +6,7 @@ package app
import (
"net/http"
"regexp"
+ "time"
l4g "github.com/alecthomas/log4go"
"github.com/dyatlov/go-opengraph/opengraph"
@@ -15,6 +16,14 @@ import (
"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) {
// Check that channel has not been deleted
var channel *model.Channel
@@ -169,8 +178,6 @@ func handlePostEvents(post *model.Post, teamId string, triggerWebhooks bool) *mo
return nil
}
-var linkWithTextRegex *regexp.Regexp = regexp.MustCompile(`<([^<\|]+)\|([^>]+)>`)
-
// This method only parses and processes the attachments,
// all else should be set in the post which is passed
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 {
og := opengraph.NewOpenGraph()
- res, err := http.Get(url)
+ res, err := c.Get(url)
if err != nil {
return og
}