summaryrefslogtreecommitdiff
path: root/internal/platforms
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-10-18 22:03:01 +0300
committerPaul Buetow <paul@buetow.org>2024-10-18 22:03:01 +0300
commitd20ce579021f3dc087cbcb19a2e0cb2f9a4db113 (patch)
treeb3f29756524637b8d5ba6fa9c1ebe8ecefa30c8a /internal/platforms
parentee2cb360bfb6ab35cb8a373fd1237993cea168d0 (diff)
can edit a post before posting int
Diffstat (limited to 'internal/platforms')
-rw-r--r--internal/platforms/linkedin/linkedin.go9
-rw-r--r--internal/platforms/mastodon/mastodon.go7
2 files changed, 9 insertions, 7 deletions
diff --git a/internal/platforms/linkedin/linkedin.go b/internal/platforms/linkedin/linkedin.go
index d8eb91e..b07ab70 100644
--- a/internal/platforms/linkedin/linkedin.go
+++ b/internal/platforms/linkedin/linkedin.go
@@ -42,13 +42,8 @@ func post(ctx context.Context, args config.Args, sizeLimit int, ent entry.Entry)
return err
}
if err := prompt.DoYouWantThis("Do you want to post this message to Linkedin?", content); err != nil {
- // TODO: Do the same for Mastodon. Gan this be more generalized?
- if err == prompt.ErrEditContent {
- if err := prompt.EditFile(ent.Path); err != nil {
- return err
- }
- ent, err = entry.New(ent.Path)
- if err != err {
+ if errors.Is(err, prompt.ErrEditContent) {
+ if err := ent.Edit(); err != nil {
return err
}
return post(ctx, args, sizeLimit, ent)
diff --git a/internal/platforms/mastodon/mastodon.go b/internal/platforms/mastodon/mastodon.go
index d4f9e7b..f582b4c 100644
--- a/internal/platforms/mastodon/mastodon.go
+++ b/internal/platforms/mastodon/mastodon.go
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
+ "errors"
"fmt"
"log"
"net/http"
@@ -28,6 +29,12 @@ func Post(ctx context.Context, args config.Args, sizeLimit int, ent entry.Entry)
return nil
}
if err := prompt.DoYouWantThis("Do you want to post this message to Mastodon?", content); err != nil {
+ if errors.Is(err, prompt.ErrEditContent) {
+ if err := ent.Edit(); err != nil {
+ return err
+ }
+ return Post(ctx, args, sizeLimit, ent)
+ }
return err
}
req, err := http.NewRequestWithContext(ctx, "POST", args.Secrets.MastodonURL, bytes.NewBuffer(payloadBytes))