mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2025-05-10 13:58:46 +00:00
update README and hardcode poll options to 20
This commit is contained in:
parent
8dcd6cfdd7
commit
4c0c1c40a8
7 changed files with 76 additions and 2 deletions
|
@ -978,7 +978,8 @@ 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, scheduledAt string) (id string, err error) {
|
||||
files []*multipart.FileHeader, edit string, language string, expiresIn int, scheduledAt string,
|
||||
pollOptions []string, pollExpiresIn int, pollHideTotals bool, pollMultiple bool) (id string, err error) {
|
||||
|
||||
var mediaIDs []string
|
||||
for _, f := range files {
|
||||
|
@ -991,6 +992,13 @@ func (s *service) Post(c *client, content string, replyToID string,
|
|||
|
||||
expiresIn = expiresIn * 3600
|
||||
|
||||
pollTweet := mastodon.TootPoll{
|
||||
ExpiresIn: pollExpiresIn,
|
||||
Options: pollOptions,
|
||||
Multiple: pollMultiple,
|
||||
HideTotals: pollHideTotals,
|
||||
}
|
||||
|
||||
tweet := &mastodon.Toot{
|
||||
SpoilerText: spoilerText,
|
||||
Status: content,
|
||||
|
@ -1003,6 +1011,7 @@ func (s *service) Post(c *client, content string, replyToID string,
|
|||
Language: language,
|
||||
ExpiresIn: expiresIn, // pleroma compatible
|
||||
ScheduledAt: scheduledAt,
|
||||
Poll: pollTweet,
|
||||
}
|
||||
|
||||
st, err := c.PostStatus(c.ctx, tweet)
|
||||
|
|
|
@ -327,8 +327,22 @@ func NewHandler(s *service, verbose bool, staticDir string) http.Handler {
|
|||
}
|
||||
scheduledAt = string(scheduled.UTC().Format(time.RFC3339))
|
||||
}
|
||||
var pollOptions []string
|
||||
for i := 0; i < 16; i++ {
|
||||
v := c.r.FormValue(fmt.Sprintf("poll-option-%d", i))
|
||||
if len(v) == 0 {
|
||||
continue
|
||||
}
|
||||
pollOptions = append(pollOptions, v)
|
||||
}
|
||||
pollExpiresIn, err := strconv.Atoi(c.r.FormValue("poll-expires-in"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pollHideTotals := c.r.FormValue("poll-hide-totals") == "true"
|
||||
pollMultiple := c.r.FormValue("poll-is-multiple") == "true"
|
||||
|
||||
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit, language, expiresIn, scheduledAt)
|
||||
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit, language, expiresIn, scheduledAt, pollOptions, pollExpiresIn, pollHideTotals, pollMultiple)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue