Update Mattermost to v5.4

This commit is contained in:
Hanzei 2018-10-17 07:10:52 +02:00
parent b9e17a1c5f
commit e30e2613a4
No known key found for this signature in database
GPG key ID: 69A2DEFD98937BA0
26 changed files with 4888 additions and 4204 deletions

View file

@ -401,6 +401,14 @@ func (c *Client4) GetRedirectLocationRoute() string {
return fmt.Sprintf("/redirect_location")
}
func (c *Client4) GetRegisterTermsOfServiceRoute(userId string) string {
return c.GetUserRoute(userId) + "/terms_of_service"
}
func (c *Client4) GetTermsOfServiceRoute() string {
return "/terms_of_service"
}
func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) {
return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag)
}
@ -1961,6 +1969,17 @@ func (c *Client4) AutocompleteChannelsForTeam(teamId, name string) (*ChannelList
}
}
// AutocompleteChannelsForTeamForSearch will return an ordered list of your channels autocomplete suggestions
func (c *Client4) AutocompleteChannelsForTeamForSearch(teamId, name string) (*ChannelList, *Response) {
query := fmt.Sprintf("?name=%v", name)
if r, err := c.DoApiGet(c.GetChannelsForTeamRoute(teamId)+"/search_autocomplete"+query, ""); err != nil {
return nil, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
return ChannelListFromJson(r.Body), BuildResponse(r)
}
}
// Post Section
// CreatePost creates a post based on the provided post struct.
@ -2157,17 +2176,6 @@ func (c *Client4) SearchPostsWithParams(teamId string, params *SearchParameter)
}
}
// SearchPosts returns any posts with matching terms string including deleted channels.
func (c *Client4) SearchPostsIncludeDeletedChannels(teamId string, terms string, isOrSearch bool) (*PostList, *Response) {
requestBody := map[string]interface{}{"terms": terms, "is_or_search": isOrSearch}
if r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/posts/search?include_deleted_channels=true", StringInterfaceToJson(requestBody)); err != nil {
return nil, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
return PostListFromJson(r.Body), BuildResponse(r)
}
}
// 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}
@ -3794,3 +3802,38 @@ func (c *Client4) GetRedirectLocation(urlParam, etag string) (string, *Response)
return MapFromJson(r.Body)["location"], BuildResponse(r)
}
}
func (c *Client4) RegisteTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*bool, *Response) {
url := c.GetRegisterTermsOfServiceRoute(userId)
data := map[string]interface{}{"termsOfServiceId": termsOfServiceId, "accepted": accepted}
if r, err := c.DoApiPost(url, StringInterfaceToJson(data)); err != nil {
return nil, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
return NewBool(CheckStatusOK(r)), BuildResponse(r)
}
}
func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
url := c.GetTermsOfServiceRoute()
if r, err := c.DoApiGet(url, etag); err != nil {
return nil, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
return TermsOfServiceFromJson(r.Body), BuildResponse(r)
}
}
func (c *Client4) CreateTermsOfService(text, userId string) (*TermsOfService, *Response) {
url := c.GetTermsOfServiceRoute()
data := map[string]string{"text": text}
if r, err := c.DoApiPost(url, MapToJson(data)); err != nil {
return nil, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
return TermsOfServiceFromJson(r.Body), BuildResponse(r)
}
}