From 8e23c12025fac69c6c08aa37e690ee24978c6eed Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 9 Oct 2024 23:28:21 +0300 Subject: can abort --- internal/platforms/mastodon/mastodon.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'internal/platforms/mastodon') diff --git a/internal/platforms/mastodon/mastodon.go b/internal/platforms/mastodon/mastodon.go index a933ea6..361d1a5 100644 --- a/internal/platforms/mastodon/mastodon.go +++ b/internal/platforms/mastodon/mastodon.go @@ -9,6 +9,7 @@ import ( "codeberg.org/snonux/gos/internal/config" "codeberg.org/snonux/gos/internal/entry" + "codeberg.org/snonux/gos/internal/prompt" ) func Post(ctx context.Context, args config.Args, ent entry.Entry) error { @@ -21,6 +22,9 @@ func Post(ctx context.Context, args config.Args, ent entry.Entry) error { if err != nil { return fmt.Errorf("failed to marshal payload: %w", err) } + if !prompt.Yes(fmt.Sprintf("%s\nDo you want to post this message to Mastodon?", string(payloadBytes))) { + return prompt.ErrAborted + } req, err := http.NewRequest("POST", args.Secrets.MastodonURL, bytes.NewBuffer(payloadBytes)) if err != nil { -- cgit v1.2.3