From c095b7fb273eed04cae0d42cae2d534cf74cfd9e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 22 Nov 2024 23:48:28 +0200 Subject: some stuff all around --- internal/platforms/platform.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'internal/platforms') 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 +} -- cgit v1.2.3