diff options
| author | Paul Buetow <paul@buetow.org> | 2024-11-27 21:29:36 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-11-27 21:29:36 +0200 |
| commit | 613862e874cb260e98b5dcdef37eee1b2ca9bf63 (patch) | |
| tree | 53a990802bdee32d9daf152454f28dffcb7f5109 /internal | |
| parent | 2a4a54ae8ff2b46c3f050b0fafd706d979c0a2c4 (diff) | |
fix edit bug for mastodon
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/platforms/mastodon/mastodon.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/platforms/mastodon/mastodon.go b/internal/platforms/mastodon/mastodon.go index e639b47..938cf6f 100644 --- a/internal/platforms/mastodon/mastodon.go +++ b/internal/platforms/mastodon/mastodon.go @@ -22,19 +22,20 @@ func Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) if err != nil { return err } - payload := map[string]string{"status": content} - payloadBytes, err := json.Marshal(payload) - if err != nil { - return fmt.Errorf("failed to marshal payload: %w", err) - } if args.DryRun { colour.Infoln("Not posting", en, "to Mastodon as dry-run enabled") return nil } - if _, err = prompt.FileAction("Do you want to post this message to Mastodon?", content, en.Path); err != nil { + if content, err = prompt.FileAction("Do you want to post this message to Mastodon?", content, en.Path); err != nil { return err } + payload := map[string]string{"status": content} + payloadBytes, err := json.Marshal(payload) + if err != nil { + return fmt.Errorf("failed to marshal payload: %w", err) + } + newCtx, cancel := context.WithTimeout(ctx, mastodonTimeout) defer cancel() req, err := http.NewRequestWithContext(newCtx, "POST", args.Secrets.MastodonURL, bytes.NewBuffer(payloadBytes)) |
