Merge pull request #40 from orzFly/patch/post-status-todo
Implement MediaIDs, Visibility, Sensitive and SpoilerText in PostStatuspull/42/head
commit
8bb9182901
17
status.go
17
status.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Status is struct to hold status.
|
// 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 {
|
if toot.InReplyToID > 0 {
|
||||||
params.Set("in_reply_to_id", fmt.Sprint(toot.InReplyToID))
|
params.Set("in_reply_to_id", fmt.Sprint(toot.InReplyToID))
|
||||||
}
|
}
|
||||||
// TODO: media_ids, senstitive, spoiler_text, visibility
|
if toot.MediaIDs != nil {
|
||||||
//params.Set("visibility", "public")
|
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
|
var status Status
|
||||||
err := c.doAPI(ctx, http.MethodPost, "/api/v1/statuses", params, &status, nil)
|
err := c.doAPI(ctx, http.MethodPost, "/api/v1/statuses", params, &status, nil)
|
||||||
|
|
Loading…
Reference in New Issue