summaryrefslogtreecommitdiffstats
path: root/app/post.go
diff options
context:
space:
mode:
authorJosta Yee <jostyee@users.noreply.github.com>2017-03-01 06:59:53 +0800
committerJoram Wilander <jwawilander@gmail.com>2017-02-28 17:59:53 -0500
commit23be0167f478765eb67ba21ab8837b0cbff8705a (patch)
tree8cb74a99fac4f7d2a1143f57fd36c9fed52645bf /app/post.go
parent838bb8cee2dbfb5c1f6560154a603fcc000f6244 (diff)
downloadchat-23be0167f478765eb67ba21ab8837b0cbff8705a.tar.gz
chat-23be0167f478765eb67ba21ab8837b0cbff8705a.tar.bz2
chat-23be0167f478765eb67ba21ab8837b0cbff8705a.zip
Set timeout to http client (#5540)
Update client
Diffstat (limited to 'app/post.go')
-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
}