mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 04:39:21 +02:00
Feature: Bare bones Editing implimented
This commit is contained in:
parent
4df1f096be
commit
53353c0e64
|
@ -260,6 +260,7 @@ func (c *Client) GetAccessToken(ctx context.Context) string {
|
|||
|
||||
// Toot is struct to post status.
|
||||
type Toot struct {
|
||||
Edit string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
InReplyToID string `json:"in_reply_to_id"`
|
||||
MediaIDs []string `json:"media_ids"`
|
||||
|
|
|
@ -333,10 +333,16 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) {
|
|||
params.Set("content_type", toot.ContentType)
|
||||
}
|
||||
var status Status
|
||||
err := c.doAPI(ctx, http.MethodPost, "/api/v1/statuses", params, &status, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if toot.Edit != "" {
|
||||
err := c.doAPI(ctx, http.MethodPut, fmt.Sprintf("/api/v1/statuses/%s", toot.Edit), params, &status, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err := c.doAPI(ctx, http.MethodPost, "/api/v1/statuses", params, &status, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return &status, nil
|
||||
}
|
||||
|
|
|
@ -986,7 +986,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) (id string, err error) {
|
||||
files []*multipart.FileHeader, edit string) (id string, err error) {
|
||||
|
||||
var mediaIDs []string
|
||||
for _, f := range files {
|
||||
|
@ -1005,6 +1005,7 @@ func (s *service) Post(c *client, content string, replyToID string,
|
|||
ContentType: format,
|
||||
Visibility: visibility,
|
||||
Sensitive: isNSFW,
|
||||
Edit: edit,
|
||||
}
|
||||
st, err := c.PostStatus(c.ctx, tweet)
|
||||
if err != nil {
|
||||
|
|
|
@ -282,8 +282,9 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
|||
isNSFW := c.r.FormValue("is_nsfw") == "true"
|
||||
quickReply := c.r.FormValue("quickreply") == "true"
|
||||
files := c.r.MultipartForm.File["attachments"]
|
||||
edit := c.r.FormValue("edit-status-id")
|
||||
|
||||
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files)
|
||||
id, err := s.Post(c, content, replyToID, format, visibility, isNSFW, spoilerText, files, edit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
</div>
|
||||
<button type="submit" accesskey="P" title="Post (P)"> Post </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">
|
||||
</form>
|
||||
{{end}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue