MM-12843 Add interactive dialogs (#9816)

* Add interactive dialogs

* Fix unit test

* Updates per feedback

* Fix typo

* Updates per feedback, add icon_url and error returns

* Updates per feedback

* Update per feedback
Этот коммит содержится в:
Joram Wilander
2018-11-19 15:27:17 -05:00
коммит произвёл GitHub
родитель 7a6f957638
Коммит 8cfca681b0
23 изменённых файлов: 1286 добавлений и 516 удалений

Просмотреть файл

@@ -5,6 +5,7 @@ package model
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
@@ -2224,7 +2225,7 @@ func (c *Client4) SearchPostsWithParams(teamId string, params *SearchParameter)
}
}
// SearchPosts returns any posts with matching terms string, including .
// SearchPosts returns any posts with matching terms string, including.
func (c *Client4) SearchPostsWithMatches(teamId string, terms string, isOrSearch bool) (*PostSearchResults, *Response) {
requestBody := map[string]interface{}{"terms": terms, "is_or_search": isOrSearch}
if r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/posts/search", StringInterfaceToJson(requestBody)); err != nil {
@@ -2245,6 +2246,34 @@ func (c *Client4) DoPostAction(postId, actionId string) (bool, *Response) {
}
}
// OpenInteractiveDialog sends a WebSocket event to a user's clients to
// open interactive dialogs, based on the provided trigger ID and other
// provided data. Used with interactive message buttons, menus and
// slash commands.
func (c *Client4) OpenInteractiveDialog(request OpenDialogRequest) (bool, *Response) {
b, _ := json.Marshal(request)
if r, err := c.DoApiPost("/actions/dialogs/open", string(b)); err != nil {
return false, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
return CheckStatusOK(r), BuildResponse(r)
}
}
// SubmitInteractiveDialog will submit the provided dialog data to the integration
// configured by the URL. Used with the interactive dialogs integration feature.
func (c *Client4) SubmitInteractiveDialog(request SubmitDialogRequest) (*SubmitDialogResponse, *Response) {
b, _ := json.Marshal(request)
if r, err := c.DoApiPost("/actions/dialogs/submit", string(b)); err != nil {
return nil, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
var resp SubmitDialogResponse
json.NewDecoder(r.Body).Decode(&resp)
return &resp, BuildResponse(r)
}
}
// File Section
// UploadFile will upload a file to a channel using a multipart request, to be later attached to a post.