diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-05-05 16:35:03 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-05-05 16:35:03 -0400 |
commit | d2ddf40f56191c1770c3ca93d747a7f1b749f26c (patch) | |
tree | 9cd5d9ac9fc5b9da21fba8df9990c5f927801272 /model | |
parent | 696ffb4745bec6306f88c5693b8ded89a47f5de7 (diff) | |
download | chat-d2ddf40f56191c1770c3ca93d747a7f1b749f26c.tar.gz chat-d2ddf40f56191c1770c3ca93d747a7f1b749f26c.tar.bz2 chat-d2ddf40f56191c1770c3ca93d747a7f1b749f26c.zip |
PLT-2600/PLT-2770 Added Get Public Link modal and added new API for public file links (#2892)
* Switched public file links to use a GetLinkModal
* Separated getFile and the new getPublicFile api calls
Diffstat (limited to 'model')
-rw-r--r-- | model/client.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/model/client.go b/model/client.go index 804b0d218..54f143cfe 100644 --- a/model/client.go +++ b/model/client.go @@ -993,12 +993,19 @@ func (c *Client) GetFileInfo(url string) (*Result, *AppError) { } } -func (c *Client) GetPublicLink(data map[string]string) (*Result, *AppError) { - if r, err := c.DoApiPost(c.GetTeamRoute()+"/files/get_public_link", MapToJson(data)); err != nil { +func (c *Client) GetPublicLink(filename string) (*Result, *AppError) { + if r, err := c.DoApiPost(c.GetTeamRoute()+"/files/get_public_link", MapToJson(map[string]string{"filename": filename})); err != nil { return nil, err } else { + var link string + if body, err := ioutil.ReadAll(r.Body); err == nil { + link = string(body) + } else { + // all the other Client methods return an empty string on invalid json, so we can too + } + return &Result{r.Header.Get(HEADER_REQUEST_ID), - r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil + r.Header.Get(HEADER_ETAG_SERVER), link}, nil } } |