mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* #132 Added some comments for API client * #132 fixed godoc formatting * #138 fixed go formatting
This commit is contained in:
committed by
George Goldberg
parent
be8be3a6dc
commit
60393f1cad
@@ -3069,7 +3069,7 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
success, resp := Client.RegisteTermsOfServiceAction(th.BasicUser.Id, "st_1", true)
|
||||
success, resp := Client.RegisterTermsOfServiceAction(th.BasicUser.Id, "st_1", true)
|
||||
CheckErrorMessage(t, resp, "store.sql_terms_of_service_store.get.no_rows.app_error")
|
||||
|
||||
termsOfService, err := th.App.CreateTermsOfService("terms of service", th.BasicUser.Id)
|
||||
@@ -3077,7 +3077,7 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
success, resp = Client.RegisteTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
||||
success, resp = Client.RegisterTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.True(t, *success)
|
||||
@@ -3100,7 +3100,7 @@ func TestGetUserTermsOfService(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
success, resp := Client.RegisteTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
||||
success, resp := Client.RegisterTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
||||
CheckNoError(t, resp)
|
||||
assert.True(t, *success)
|
||||
|
||||
|
||||
@@ -3919,7 +3919,8 @@ 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) {
|
||||
// RegisterTermsOfServiceAction saves action performed by a user against a specific terms of service.
|
||||
func (c *Client4) RegisterTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*bool, *Response) {
|
||||
url := c.GetUserTermsOfServiceRoute(userId)
|
||||
data := map[string]interface{}{"termsOfServiceId": termsOfServiceId, "accepted": accepted}
|
||||
r, err := c.DoApiPost(url, StringInterfaceToJson(data))
|
||||
@@ -3930,6 +3931,7 @@ func (c *Client4) RegisteTermsOfServiceAction(userId, termsOfServiceId string, a
|
||||
return NewBool(CheckStatusOK(r)), BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetTermsOfService fetches the latest terms of service
|
||||
func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
|
||||
url := c.GetTermsOfServiceRoute()
|
||||
r, err := c.DoApiGet(url, etag)
|
||||
@@ -3940,6 +3942,7 @@ func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
|
||||
return TermsOfServiceFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetUserTermsOfService fetches user's latest terms of service action if the latest action was for acceptance.
|
||||
func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfService, *Response) {
|
||||
url := c.GetUserTermsOfServiceRoute(userId)
|
||||
r, err := c.DoApiGet(url, etag)
|
||||
@@ -3950,6 +3953,7 @@ func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfServic
|
||||
return UserTermsOfServiceFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// CreateTermsOfService creates new terms of service.
|
||||
func (c *Client4) CreateTermsOfService(text, userId string) (*TermsOfService, *Response) {
|
||||
url := c.GetTermsOfServiceRoute()
|
||||
data := map[string]interface{}{"text": text}
|
||||
|
||||
Reference in New Issue
Block a user