mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-26 13:51:28 +00:00
Compare commits
2 commits
44f8a72a76
...
6a233f6cb2
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | 6a233f6cb2 | ||
localhost_frssoft | 4cd8fb2ddb |
|
@ -210,6 +210,9 @@ type Toot struct {
|
||||||
SpoilerText string `json:"spoiler_text"`
|
SpoilerText string `json:"spoiler_text"`
|
||||||
Visibility string `json:"visibility"`
|
Visibility string `json:"visibility"`
|
||||||
ContentType string `json:"content_type"`
|
ContentType string `json:"content_type"`
|
||||||
|
Language string `json:"language"`
|
||||||
|
ExpiresIn int `json:"expires_in"`
|
||||||
|
ScheduledAt string `json:"scheduled_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mention hold information for mention.
|
// Mention hold information for mention.
|
||||||
|
|
|
@ -358,6 +358,16 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) {
|
||||||
if toot.ContentType != "" {
|
if toot.ContentType != "" {
|
||||||
params.Set("content_type", toot.ContentType)
|
params.Set("content_type", toot.ContentType)
|
||||||
}
|
}
|
||||||
|
if toot.Language != "" {
|
||||||
|
params.Set("language", toot.Language)
|
||||||
|
}
|
||||||
|
if toot.ExpiresIn >= 3600 {
|
||||||
|
params.Set("expires_in", fmt.Sprint(toot.ExpiresIn))
|
||||||
|
}
|
||||||
|
if toot.ScheduledAt != "" {
|
||||||
|
params.Set("scheduled_at", toot.ScheduledAt)
|
||||||
|
}
|
||||||
|
|
||||||
var status Status
|
var status Status
|
||||||
if toot.Edit != "" {
|
if toot.Edit != "" {
|
||||||
err := c.doAPI(ctx, http.MethodPut, fmt.Sprintf("/api/v1/statuses/%s", toot.Edit), params, &status, nil)
|
err := c.doAPI(ctx, http.MethodPut, fmt.Sprintf("/api/v1/statuses/%s", toot.Edit), params, &status, nil)
|
||||||
|
|
|
@ -988,7 +988,7 @@ func (s *service) Signout(c *client) (err error) {
|
||||||
|
|
||||||
func (s *service) Post(c *client, content string, replyToID string,
|
func (s *service) Post(c *client, content string, replyToID string,
|
||||||
format string, visibility string, isNSFW bool, spoilerText string,
|
format string, visibility string, isNSFW bool, spoilerText string,
|
||||||
files []*multipart.FileHeader, edit string) (id string, err error) {
|
files []*multipart.FileHeader, edit string, language string, expiresIn int, scheduledAt string) (id string, err error) {
|
||||||
|
|
||||||
var mediaIDs []string
|
var mediaIDs []string
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
|
@ -999,6 +999,8 @@ func (s *service) Post(c *client, content string, replyToID string,
|
||||||
mediaIDs = append(mediaIDs, a.ID)
|
mediaIDs = append(mediaIDs, a.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expiresIn = expiresIn * 3600
|
||||||
|
|
||||||
tweet := &mastodon.Toot{
|
tweet := &mastodon.Toot{
|
||||||
SpoilerText: spoilerText,
|
SpoilerText: spoilerText,
|
||||||
Status: content,
|
Status: content,
|
||||||
|
@ -1008,7 +1010,11 @@ func (s *service) Post(c *client, content string, replyToID string,
|
||||||
Visibility: visibility,
|
Visibility: visibility,
|
||||||
Sensitive: isNSFW,
|
Sensitive: isNSFW,
|
||||||
Edit: edit,
|
Edit: edit,
|
||||||
|
Language: language,
|
||||||
|
ExpiresIn: expiresIn, // pleroma compatible
|
||||||
|
ScheduledAt: scheduledAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := c.PostStatus(c.ctx, tweet)
|
st, err := c.PostStatus(c.ctx, tweet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -314,8 +314,21 @@ func NewHandler(s *service, verbose bool, staticDir string) http.Handler {
|
||||||
quickReply := c.r.FormValue("quickreply") == "true"
|
quickReply := c.r.FormValue("quickreply") == "true"
|
||||||
files := c.r.MultipartForm.File["attachments"]
|
files := c.r.MultipartForm.File["attachments"]
|
||||||
edit := c.r.FormValue("edit-status-id")
|
edit := c.r.FormValue("edit-status-id")
|
||||||
|
language := c.r.FormValue("lang-code")
|
||||||
|
expiresIn, err := strconv.Atoi(c.r.FormValue("expires-in"))
|
||||||
|
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)
|
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit, language, expiresIn, scheduledAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
<button type="submit" accesskey="P" title="Post (P)"> Post </button>
|
<button type="submit" accesskey="P" title="Post (P)"> Post </button>
|
||||||
<button type="reset" title="Reset"> Reset </button>
|
<button type="reset" title="Reset"> Reset </button>
|
||||||
<input id="edit-status-id" name="edit-status-id" placeholder="Input Status ID for edit" title="Edit ID">
|
<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>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue