add scheduled status

This commit is contained in:
localhost_frssoft 2023-11-10 01:27:22 +03:00
parent 4cd8fb2ddb
commit 6a233f6cb2
5 changed files with 17 additions and 3 deletions

View file

@ -988,7 +988,7 @@ func (s *service) Signout(c *client) (err error) {
func (s *service) Post(c *client, content string, replyToID string,
format string, visibility string, isNSFW bool, spoilerText string,
files []*multipart.FileHeader, edit string, language string, expiresIn int) (id string, err error) {
files []*multipart.FileHeader, edit string, language string, expiresIn int, scheduledAt string) (id string, err error) {
var mediaIDs []string
for _, f := range files {
@ -1012,6 +1012,7 @@ func (s *service) Post(c *client, content string, replyToID string,
Edit: edit,
Language: language,
ExpiresIn: expiresIn, // pleroma compatible
ScheduledAt: scheduledAt,
}
st, err := c.PostStatus(c.ctx, tweet)

View file

@ -319,8 +319,16 @@ func NewHandler(s *service, verbose bool, staticDir string) http.Handler {
if err != nil {
return err
}
scheduledAt := c.r.FormValue("scheduled")
if scheduledAt != "" {
scheduled, err := time.Parse("2006-01-02T15:04", scheduledAt)
if err != nil {
return err
}
scheduledAt = string(scheduled.UTC().Format(time.RFC3339))
}
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit, language, expiresIn)
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit, language, expiresIn, scheduledAt)
if err != nil {
return err
}