mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-05 14:43:01 +00:00
add scheduled status
This commit is contained in:
parent
4cd8fb2ddb
commit
6a233f6cb2
@ -211,7 +211,8 @@ type Toot struct {
|
||||
Visibility string `json:"visibility"`
|
||||
ContentType string `json:"content_type"`
|
||||
Language string `json:"language"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
ScheduledAt string `json:"scheduled_at"`
|
||||
}
|
||||
|
||||
// Mention hold information for mention.
|
||||
|
@ -364,6 +364,9 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) {
|
||||
if toot.ExpiresIn >= 3600 {
|
||||
params.Set("expires_in", fmt.Sprint(toot.ExpiresIn))
|
||||
}
|
||||
if toot.ScheduledAt != "" {
|
||||
params.Set("scheduled_at", toot.ScheduledAt)
|
||||
}
|
||||
|
||||
var status Status
|
||||
if toot.Edit != "" {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -50,6 +50,7 @@
|
||||
<input id="edit-status-id" name="edit-status-id" placeholder="Input Status ID for edit" title="Edit ID">
|
||||
<input id="lang-code" name="lang-code" placeholder="lang" title="Post language (ISO 639) [en, ru, etc..] Default: none" size="4">
|
||||
<input type="number" id="expires-in" name="expires-in" title="Post autodeleted after hour(s)" min="0" value="0" size="4">
|
||||
<input type="datetime-local" id="scheduled" name="scheduled" step=300 title="Schedule your status (timezone UTC+0)">
|
||||
</form>
|
||||
{{end}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user