summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-05-10 12:44:18 +0200
committerGeorge Goldberg <george@gberg.me>2017-05-10 11:44:18 +0100
commit16581ae431ffeae97db18eb8672232505a7ce3c0 (patch)
treeb87317febf6f2ee4588fa3c8b48ed7a1cf81c048 /model
parentb9f4ced52b65d147b57d7028f6df4935a6aea8f9 (diff)
downloadchat-16581ae431ffeae97db18eb8672232505a7ce3c0.tar.gz
chat-16581ae431ffeae97db18eb8672232505a7ce3c0.tar.bz2
chat-16581ae431ffeae97db18eb8672232505a7ce3c0.zip
implement open graph metadata for apiV4 (#6343)
Diffstat (limited to 'model')
-rw-r--r--model/client4.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index 7e0cd1acf..91c5b2b5f 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -250,6 +250,10 @@ func (c *Client4) GetOAuthAppRoute(appId string) string {
return fmt.Sprintf("/oauth/apps/%v", appId)
}
+func (c *Client4) GetOpenGraphRoute() string {
+ return fmt.Sprintf("/opengraph")
+}
+
func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) {
return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag)
}
@@ -2575,3 +2579,18 @@ func (c *Client4) DeleteReaction(reaction *Reaction) (bool, *Response) {
return CheckStatusOK(r), BuildResponse(r)
}
}
+
+// Open Graph Metadata Section
+
+// OpenGraph return the open graph metadata for a particular url if the site have the metadata
+func (c *Client4) OpenGraph(url string) (map[string]string, *Response) {
+ requestBody := make(map[string]string)
+ requestBody["url"] = url
+
+ if r, err := c.DoApiPost(c.GetOpenGraphRoute(), MapToJson(requestBody)); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return MapFromJson(r.Body), BuildResponse(r)
+ }
+}