From 16581ae431ffeae97db18eb8672232505a7ce3c0 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Wed, 10 May 2017 12:44:18 +0200 Subject: implement open graph metadata for apiV4 (#6343) --- model/client4.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'model') 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) + } +} -- cgit v1.2.3-1-g7c22