From 563ea5dbaaa77e59939812d6825d54cf829db8eb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 17 Oct 2024 10:38:40 +0300 Subject: implement sizeLimit per platform --- internal/run.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'internal/run.go') diff --git a/internal/run.go b/internal/run.go index acf0525..ed70511 100644 --- a/internal/run.go +++ b/internal/run.go @@ -20,8 +20,8 @@ func Run(ctx context.Context, args config.Args) error { return err } - for _, platform := range args.Platforms { - if err := runPlatform(ctx, args, platform); err != nil { + for platform, sizeLimit := range args.Platforms { + if err := runPlatform(ctx, args, platform, sizeLimit); err != nil { if errors.Is(err, prompt.ErrAborted) { log.Println("Aborted posting to", platform) continue @@ -33,7 +33,7 @@ func Run(ctx context.Context, args config.Args) error { return nil } -func runPlatform(ctx context.Context, args config.Args, platform string) error { +func runPlatform(ctx context.Context, args config.Args, platform string, sizeLimit int) error { ent, err := schedule.Run(args, platform) switch { case errors.Is(err, schedule.ErrNothingToSchedule): @@ -47,7 +47,7 @@ func runPlatform(ctx context.Context, args config.Args, platform string) error { } log.Println("Scheduling", ent) - var postCB func(context.Context, config.Args, entry.Entry) error + var postCB func(context.Context, config.Args, int, entry.Entry) error switch strings.ToLower(platform) { case "mastodon": postCB = mastodon.Post @@ -57,7 +57,7 @@ func runPlatform(ctx context.Context, args config.Args, platform string) error { log.Fatal("Platform", platform, "(not yet) implemented") } - if err := postCB(ctx, args, ent); err != nil { + if err := postCB(ctx, args, sizeLimit, ent); err != nil { return err } -- cgit v1.2.3