summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v5/model/client4.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-12-31 14:48:12 +0100
committerGitHub <noreply@github.com>2020-12-31 14:48:12 +0100
commit4f20ebead36876a88391bf033d1de3e4cf0228da (patch)
tree70b6fd79c6a5e00c958c29a7bd3926f074e76ba6 /vendor/github.com/mattermost/mattermost-server/v5/model/client4.go
parenta9f89dbc645aafc68daa9fc8d589f55104b535c7 (diff)
downloadmatterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.tar.gz
matterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.tar.bz2
matterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.zip
Update vendor for next release (#1343)
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v5/model/client4.go')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/model/client4.go209
1 files changed, 208 insertions, 1 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/model/client4.go b/vendor/github.com/mattermost/mattermost-server/v5/model/client4.go
index b3c34c39..8ebf0da1 100644
--- a/vendor/github.com/mattermost/mattermost-server/v5/model/client4.go
+++ b/vendor/github.com/mattermost/mattermost-server/v5/model/client4.go
@@ -189,6 +189,14 @@ func (c *Client4) GetUserRoute(userId string) string {
return fmt.Sprintf(c.GetUsersRoute()+"/%v", userId)
}
+func (c *Client4) GetUserThreadsRoute(userId string) string {
+ return fmt.Sprintf(c.GetUsersRoute()+"/%v/threads", userId)
+}
+
+func (c *Client4) GetUserThreadRoute(userId, threadId string) string {
+ return fmt.Sprintf(c.GetUserThreadsRoute(userId)+"/%v", threadId)
+}
+
func (c *Client4) GetUserCategoryRoute(userID, teamID string) string {
return c.GetUserRoute(userID) + c.GetTeamRoute(teamID) + "/channels/categories"
}
@@ -334,6 +342,10 @@ func (c *Client4) GetSystemRoute() string {
return "/system"
}
+func (c *Client4) GetCloudRoute() string {
+ return "/cloud"
+}
+
func (c *Client4) GetTestEmailRoute() string {
return "/email/test"
}
@@ -3268,6 +3280,21 @@ func (c *Client4) GetPingWithServerStatus() (string, *Response) {
return MapFromJson(r.Body)["status"], BuildResponse(r)
}
+// GetPingWithFullServerStatus will return the full status if several basic server
+// health checks all pass successfully.
+func (c *Client4) GetPingWithFullServerStatus() (map[string]string, *Response) {
+ r, err := c.DoApiGet(c.GetSystemRoute()+"/ping?get_server_status="+c.boolString(true), "")
+ if r != nil && r.StatusCode == 500 {
+ defer r.Body.Close()
+ return map[string]string{"status": STATUS_UNHEALTHY}, BuildErrorResponse(r, err)
+ }
+ if err != nil {
+ return nil, BuildErrorResponse(r, err)
+ }
+ defer closeBody(r)
+ return MapFromJson(r.Body), BuildResponse(r)
+}
+
// TestEmail will attempt to connect to the configured SMTP server.
func (c *Client4) TestEmail(config *Config) (bool, *Response) {
r, err := c.DoApiPost(c.GetTestEmailRoute(), config.ToJson())
@@ -4090,7 +4117,7 @@ func (c *Client4) MigrateAuthToSaml(fromAuthService string, usersMap map[string]
// UploadLdapPublicCertificate will upload a public certificate for LDAP and set the config to use it.
func (c *Client4) UploadLdapPublicCertificate(data []byte) (bool, *Response) {
- body, writer, err := fileToMultipart(data, LDAP_PUBIC_CERTIFICATE_NAME)
+ body, writer, err := fileToMultipart(data, LDAP_PUBLIC_CERTIFICATE_NAME)
if err != nil {
return false, &Response{Error: NewAppError("UploadLdapPublicCertificate", "model.client.upload_ldap_cert.app_error", nil, err.Error(), http.StatusBadRequest)}
}
@@ -5616,3 +5643,183 @@ func (c *Client4) UpdatePassword(userId, currentPassword, newPassword string) *R
defer closeBody(r)
return BuildResponse(r)
}
+
+// Cloud Section
+
+func (c *Client4) GetCloudProducts() ([]*Product, *Response) {
+ r, appErr := c.DoApiGet(c.GetCloudRoute()+"/products", "")
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var cloudProducts []*Product
+ json.NewDecoder(r.Body).Decode(&cloudProducts)
+
+ return cloudProducts, BuildResponse(r)
+}
+
+func (c *Client4) CreateCustomerPayment() (*StripeSetupIntent, *Response) {
+ r, appErr := c.DoApiPost(c.GetCloudRoute()+"/payment", "")
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var setupIntent *StripeSetupIntent
+ json.NewDecoder(r.Body).Decode(&setupIntent)
+
+ return setupIntent, BuildResponse(r)
+}
+
+func (c *Client4) ConfirmCustomerPayment(confirmRequest *ConfirmPaymentMethodRequest) *Response {
+ json, _ := json.Marshal(confirmRequest)
+
+ r, appErr := c.doApiPostBytes(c.GetCloudRoute()+"/payment/confirm", json)
+ if appErr != nil {
+ return BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ return BuildResponse(r)
+}
+
+func (c *Client4) GetCloudCustomer() (*CloudCustomer, *Response) {
+ r, appErr := c.DoApiGet(c.GetCloudRoute()+"/customer", "")
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var cloudCustomer *CloudCustomer
+ json.NewDecoder(r.Body).Decode(&cloudCustomer)
+
+ return cloudCustomer, BuildResponse(r)
+}
+
+func (c *Client4) GetSubscription() (*Subscription, *Response) {
+ r, appErr := c.DoApiGet(c.GetCloudRoute()+"/subscription", "")
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var subscription *Subscription
+ json.NewDecoder(r.Body).Decode(&subscription)
+
+ return subscription, BuildResponse(r)
+}
+
+func (c *Client4) GetInvoicesForSubscription() ([]*Invoice, *Response) {
+ r, appErr := c.DoApiGet(c.GetCloudRoute()+"/subscription/invoices", "")
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var invoices []*Invoice
+ json.NewDecoder(r.Body).Decode(&invoices)
+
+ return invoices, BuildResponse(r)
+}
+
+func (c *Client4) UpdateCloudCustomer(customerInfo *CloudCustomerInfo) (*CloudCustomer, *Response) {
+ customerBytes, _ := json.Marshal(customerInfo)
+
+ r, appErr := c.doApiPutBytes(c.GetCloudRoute()+"/customer", customerBytes)
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var customer *CloudCustomer
+ json.NewDecoder(r.Body).Decode(&customer)
+
+ return customer, BuildResponse(r)
+}
+
+func (c *Client4) UpdateCloudCustomerAddress(address *Address) (*CloudCustomer, *Response) {
+ addressBytes, _ := json.Marshal(address)
+
+ r, appErr := c.doApiPutBytes(c.GetCloudRoute()+"/customer/address", addressBytes)
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var customer *CloudCustomer
+ json.NewDecoder(r.Body).Decode(&customer)
+
+ return customer, BuildResponse(r)
+}
+
+func (c *Client4) GetUserThreads(userId string, options GetUserThreadsOpts) (*Threads, *Response) {
+ v := url.Values{}
+ if options.Since != 0 {
+ v.Set("since", fmt.Sprintf("%d", options.Since))
+ }
+ if options.Page != 0 {
+ v.Set("page", fmt.Sprintf("%d", options.Page))
+ }
+ if options.PageSize != 0 {
+ v.Set("pageSize", fmt.Sprintf("%d", options.PageSize))
+ }
+ if options.Extended {
+ v.Set("extended", "true")
+ }
+ if options.Deleted {
+ v.Set("deleted", "true")
+ }
+
+ url := c.GetUserThreadsRoute(userId)
+ if len(v) > 0 {
+ url += "?" + v.Encode()
+ }
+
+ r, appErr := c.DoApiGet(url, "")
+ if appErr != nil {
+ return nil, BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ var threads Threads
+ json.NewDecoder(r.Body).Decode(&threads)
+
+ return &threads, BuildResponse(r)
+}
+
+func (c *Client4) UpdateThreadsReadForUser(userId string, timestamp int64) *Response {
+ r, appErr := c.DoApiPut(fmt.Sprintf("%s/read/%d", c.GetUserThreadsRoute(userId), timestamp), "")
+ if appErr != nil {
+ return BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ return BuildResponse(r)
+}
+
+func (c *Client4) UpdateThreadReadForUser(userId, threadId string, timestamp int64) *Response {
+ r, appErr := c.DoApiPut(fmt.Sprintf("%s/read/%d", c.GetUserThreadRoute(userId, threadId), timestamp), "")
+ if appErr != nil {
+ return BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ return BuildResponse(r)
+}
+
+func (c *Client4) UpdateThreadFollowForUser(userId, threadId string, state bool) *Response {
+ var appErr *AppError
+ var r *http.Response
+ if state {
+ r, appErr = c.DoApiPut(c.GetUserThreadRoute(userId, threadId)+"/following", "")
+ } else {
+ r, appErr = c.DoApiDelete(c.GetUserThreadRoute(userId, threadId) + "/following")
+ }
+ if appErr != nil {
+ return BuildErrorResponse(r, appErr)
+ }
+ defer closeBody(r)
+
+ return BuildResponse(r)
+}