summaryrefslogtreecommitdiff
path: root/internal/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'internal/platforms')
-rw-r--r--internal/platforms/platform.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/platforms/platform.go b/internal/platforms/platform.go
index f899357..cabc446 100644
--- a/internal/platforms/platform.go
+++ b/internal/platforms/platform.go
@@ -1,8 +1,15 @@
package platforms
import (
+ "context"
"fmt"
"strings"
+
+ "codeberg.org/snonux/gos/internal/colour"
+ "codeberg.org/snonux/gos/internal/config"
+ "codeberg.org/snonux/gos/internal/entry"
+ "codeberg.org/snonux/gos/internal/platforms/linkedin"
+ "codeberg.org/snonux/gos/internal/platforms/mastodon"
)
type Platform string
@@ -30,3 +37,25 @@ func New(platformStr string) (Platform, error) {
func (p Platform) String() string {
return string(p)
}
+
+func (p Platform) Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) (err error) {
+ colour.Infoln("Posting", en)
+ switch p.String() {
+ case "mastodon":
+ err = mastodon.Post(ctx, args, sizeLimit, en)
+ case "linkedin":
+ err = linkedin.Post(ctx, args, sizeLimit, en)
+ default:
+ err = fmt.Errorf("Platform '%s' (not yet) implemented", p)
+ }
+
+ if err != nil {
+ return err
+ }
+ if err := en.MarkPosted(); err != nil {
+ return err
+ }
+
+ colour.Successf("Successfully posted message to %s", p)
+ return nil
+}