From c9a6022f50bbf733cc193cb057d91c64c0b798fb Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Sun, 23 Apr 2017 23:54:27 +0800 Subject: [PATCH] Implement MediaIDs, Visibility, Sensitive and SpoilerText in PostStatus --- status.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/status.go b/status.go index c23c731..11c750b 100644 --- a/status.go +++ b/status.go @@ -6,6 +6,7 @@ import ( "net/http" "net/url" "time" + "strconv" ) // Status is struct to hold status. @@ -173,8 +174,20 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) { if toot.InReplyToID > 0 { params.Set("in_reply_to_id", fmt.Sprint(toot.InReplyToID)) } - // TODO: media_ids, senstitive, spoiler_text, visibility - //params.Set("visibility", "public") + if toot.MediaIDs != nil { + for _, media := range toot.MediaIDs { + params.Add("media_ids[]", strconv.FormatInt(media, 10)) + } + } + if toot.Visibility != "" { + params.Set("visibility", fmt.Sprint(toot.Visibility)) + } + if toot.Sensitive { + params.Set("senstitive", "true") + } + if toot.SpoilerText != "" { + params.Set("spoiler_text", toot.SpoilerText) + } var status Status err := c.doAPI(ctx, http.MethodPost, "/api/v1/statuses", params, &status, nil)