Skip to content

Commit

Permalink
enable setting profiles for other users than the authenticated one
Browse files Browse the repository at this point in the history
  • Loading branch information
finfinack authored and james-lawrence committed Aug 31, 2019
1 parent b7ca1ed commit 215bd4e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion users.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,27 @@ func (api *Client) DeleteUserPhotoContext(ctx context.Context) error {
// the Slack API will unset the custom status/emoji. If statusExpiration is set to 0
// the status will not expire.
func (api *Client) SetUserCustomStatus(statusText, statusEmoji string, statusExpiration int64) error {
return api.SetUserCustomStatusContext(context.Background(), statusText, statusEmoji, statusExpiration)
return api.SetUserCustomStatusContextWithUser(context.Background(), "", statusText, statusEmoji, statusExpiration)
}

// SetUserCustomStatusContext will set a custom status and emoji for the currently authenticated user with a custom context
//
// For more information see SetUserCustomStatus
func (api *Client) SetUserCustomStatusContext(ctx context.Context, statusText, statusEmoji string, statusExpiration int64) error {
return api.SetUserCustomStatusContextWithUser(context.Background(), "", statusText, statusEmoji, statusExpiration)
}

// SetUserCustomStatusWithUser will set a custom status and emoji for the provided user.
//
// For more information see SetUserCustomStatus
func (api *Client) SetUserCustomStatusWithUser(user, statusText, statusEmoji string, statusExpiration int64) error {
return api.SetUserCustomStatusContextWithUser(context.Background(), user, statusText, statusEmoji, statusExpiration)
}

// SetUserCustomStatusContextWithUser will set a custom status and emoji for the provided user with a custom context
//
// For more information see SetUserCustomStatus
func (api *Client) SetUserCustomStatusContextWithUser(ctx context.Context, user, statusText, statusEmoji string, statusExpiration int64) error {
// XXX(theckman): this anonymous struct is for making requests to the Slack
// API for setting and unsetting a User's Custom Status/Emoji. To change
// these values we must provide a JSON document as the profile POST field.
Expand Down Expand Up @@ -519,6 +533,7 @@ func (api *Client) SetUserCustomStatusContext(ctx context.Context, statusText, s
}

values := url.Values{
"user": {user},
"token": {api.token},
"profile": {string(profile)},
}
Expand Down

0 comments on commit 215bd4e

Please sign in to comment.