Add scheduledAt support

pull/186/head
Victor Bersy 2023-10-29 20:26:52 +01:00
parent 9faaa4f0dc
commit 40eaccca40
No known key found for this signature in database
1 changed files with 47 additions and 29 deletions

View File

@ -44,6 +44,7 @@ type Status struct {
Application Application `json:"application"` Application Application `json:"application"`
Language string `json:"language"` Language string `json:"language"`
Pinned interface{} `json:"pinned"` Pinned interface{} `json:"pinned"`
ScheduledParams ScheduledParams `json:"params"`
} }
// StatusHistory is a struct to hold status history data. // StatusHistory is a struct to hold status history data.
@ -57,6 +58,20 @@ type StatusHistory struct {
MediaAttachments []Attachment `json:"media_attachments"` MediaAttachments []Attachment `json:"media_attachments"`
} }
// ScheduledStatus holds information returned when ScheduledAt is set on a status
type ScheduledParams struct {
ApplicationID ID `json:"application_id"`
Idempotency string `json:"idempotency"`
InReplyToID interface{} `json:"in_reply_to_id"`
MediaIDs []ID `json:"media_ids"`
Poll *Poll `json:"poll"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
Sensitive bool `json:"sensitive"`
SpoilerText string `json:"spoiler_text"`
Text string `json:"text"`
Visibility string `json:"visibility"`
}
// Context holds information for a mastodon context. // Context holds information for a mastodon context.
type Context struct { type Context struct {
Ancestors []*Status `json:"ancestors"` Ancestors []*Status `json:"ancestors"`
@ -422,6 +437,9 @@ func (c *Client) postStatus(ctx context.Context, toot *Toot, update bool, update
if toot.SpoilerText != "" { if toot.SpoilerText != "" {
params.Set("spoiler_text", toot.SpoilerText) params.Set("spoiler_text", toot.SpoilerText)
} }
if !toot.ScheduledAt.IsZero() {
params.Set("scheduled_at", toot.ScheduledAt.Format(time.RFC3339))
}
var status Status var status Status
var err error var err error