diff options
| author | Paul Buetow <paul@buetow.org> | 2024-11-22 23:48:28 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-11-22 23:48:28 +0200 |
| commit | c095b7fb273eed04cae0d42cae2d534cf74cfd9e (patch) | |
| tree | 7b12d51cae47a070622db6eb09539a31be8f0f69 /internal/platforms | |
| parent | faf7569ab307eff706e4ccf2ed92eec5c93f67eb (diff) | |
some stuff all around
Diffstat (limited to 'internal/platforms')
| -rw-r--r-- | internal/platforms/platform.go | 29 |
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 +} |
