summaryrefslogtreecommitdiffstats
path: root/api4/post.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-01-22 15:32:50 -0600
committerGitHub <noreply@github.com>2018-01-22 15:32:50 -0600
commit599991ea731953f772824ce3ed1e591246aa004f (patch)
treefca0f556f12e56bdcefa74ac6794dec64e04e3fc /api4/post.go
parenta8445775351c32f8a12081f60bda2099571b2758 (diff)
downloadchat-599991ea731953f772824ce3ed1e591246aa004f.tar.gz
chat-599991ea731953f772824ce3ed1e591246aa004f.tar.bz2
chat-599991ea731953f772824ce3ed1e591246aa004f.zip
PLT-3383: image proxy support (#7991)
* image proxy support * go vet fix, remove mistakenly added coverage file * fix test compile error * add validation to config settings and documentation to model functions * add message_source field to post
Diffstat (limited to 'api4/post.go')
-rw-r--r--api4/post.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/api4/post.go b/api4/post.go
index 7a365845f..80088d9ef 100644
--- a/api4/post.go
+++ b/api4/post.go
@@ -56,7 +56,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
post.CreateAt = 0
}
- rp, err := c.App.CreatePostAsUser(post)
+ rp, err := c.App.CreatePostAsUser(c.App.PostWithProxyRemovedFromImageURLs(post))
if err != nil {
c.Err = err
return
@@ -66,7 +66,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
c.App.UpdateLastActivityAtIfNeeded(c.Session)
w.WriteHeader(http.StatusCreated)
- w.Write([]byte(rp.ToJson()))
+ w.Write([]byte(c.App.PostWithProxyAddedToImageURLs(rp).ToJson()))
}
func getPostsForChannel(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -135,7 +135,7 @@ func getPostsForChannel(c *Context, w http.ResponseWriter, r *http.Request) {
if len(etag) > 0 {
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
}
- w.Write([]byte(list.ToJson()))
+ w.Write([]byte(c.App.PostListWithProxyAddedToImageURLs(list).ToJson()))
}
func getFlaggedPostsForUser(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -168,7 +168,7 @@ func getFlaggedPostsForUser(c *Context, w http.ResponseWriter, r *http.Request)
return
}
- w.Write([]byte(posts.ToJson()))
+ w.Write([]byte(c.App.PostListWithProxyAddedToImageURLs(posts).ToJson()))
}
func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -206,7 +206,7 @@ func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
w.Header().Set(model.HEADER_ETAG_SERVER, post.Etag())
- w.Write([]byte(post.ToJson()))
+ w.Write([]byte(c.App.PostWithProxyAddedToImageURLs(post).ToJson()))
}
}
@@ -272,7 +272,7 @@ func getPostThread(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
w.Header().Set(model.HEADER_ETAG_SERVER, list.Etag())
- w.Write([]byte(list.ToJson()))
+ w.Write([]byte(c.App.PostListWithProxyAddedToImageURLs(list).ToJson()))
}
}
@@ -313,7 +313,7 @@ func searchPosts(c *Context, w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
- w.Write([]byte(posts.ToJson()))
+ w.Write([]byte(c.App.PostListWithProxyAddedToImageURLs(posts).ToJson()))
}
func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -341,13 +341,13 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
post.Id = c.Params.PostId
- rpost, err := c.App.UpdatePost(post, false)
+ rpost, err := c.App.UpdatePost(c.App.PostWithProxyRemovedFromImageURLs(post), false)
if err != nil {
c.Err = err
return
}
- w.Write([]byte(rpost.ToJson()))
+ w.Write([]byte(c.App.PostWithProxyAddedToImageURLs(rpost).ToJson()))
}
func patchPost(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -373,13 +373,13 @@ func patchPost(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- patchedPost, err := c.App.PatchPost(c.Params.PostId, post)
+ patchedPost, err := c.App.PatchPost(c.Params.PostId, c.App.PostPatchWithProxyRemovedFromImageURLs(post))
if err != nil {
c.Err = err
return
}
- w.Write([]byte(patchedPost.ToJson()))
+ w.Write([]byte(c.App.PostWithProxyAddedToImageURLs(patchedPost).ToJson()))
}
func saveIsPinnedPost(c *Context, w http.ResponseWriter, r *http.Request, isPinned bool) {