diff options
| author | Paul Buetow <paul@buetow.org> | 2025-02-26 15:24:33 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-02-26 15:24:33 +0200 |
| commit | 547afd8c0921a7de16f0a5ce8b5d8d09bb2268c8 (patch) | |
| tree | 8490aee787d4c6f9b3e025b67d888a5367def91e /internal/platforms | |
| parent | e735b56a704b7328e7e84def46fd6d248c51e38d (diff) | |
introduce run interval
Diffstat (limited to 'internal/platforms')
| -rw-r--r-- | internal/platforms/linkedin/linkedin.go | 4 | ||||
| -rw-r--r-- | internal/platforms/linkedin/oauth2/oauth2.go | 18 | ||||
| -rw-r--r-- | internal/platforms/mastodon/mastodon.go | 4 |
3 files changed, 13 insertions, 13 deletions
diff --git a/internal/platforms/linkedin/linkedin.go b/internal/platforms/linkedin/linkedin.go index 2a3c7b2..4c63f9a 100644 --- a/internal/platforms/linkedin/linkedin.go +++ b/internal/platforms/linkedin/linkedin.go @@ -26,7 +26,7 @@ func Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) err := post(ctx, args, sizeLimit, en) if errors.Is(err, errUnauthorized) { colour.Infoln(err, "=> trying to refresh LinkedIn access token") - args.Secrets.LinkedInAccessToken = "" // Reset the token + args.Config.LinkedInAccessToken = "" // Reset the token return post(ctx, args, sizeLimit, en) } return err @@ -38,7 +38,7 @@ func post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) } timeout := linkedInTimeout - if args.Secrets.LinkedInAccessToken == "" { + if args.Config.LinkedInAccessToken == "" { // Refreshing access token requires more time due to human interaction timeout = 1 * time.Minute } diff --git a/internal/platforms/linkedin/oauth2/oauth2.go b/internal/platforms/linkedin/oauth2/oauth2.go index dfaad19..8fe25ab 100644 --- a/internal/platforms/linkedin/oauth2/oauth2.go +++ b/internal/platforms/linkedin/oauth2/oauth2.go @@ -91,15 +91,15 @@ func oauthCallbackHandler(w http.ResponseWriter, r *http.Request) { } func LinkedInCreds(ctx context.Context, args config.Args) (string, string, error) { - secrets := args.Secrets - if secrets.LinkedInAccessToken != "" && secrets.LinkedInPersonID != "" { - return secrets.LinkedInPersonID, secrets.LinkedInAccessToken, nil + conf := args.Config + if conf.LinkedInAccessToken != "" && conf.LinkedInPersonID != "" { + return conf.LinkedInPersonID, conf.LinkedInAccessToken, nil } oauthConfig = &oauth2.Config{ - ClientID: secrets.LinkedInClientID, - ClientSecret: secrets.LinkedInSecret, - RedirectURL: secrets.LinkedInRedirectURL, + ClientID: conf.LinkedInClientID, + ClientSecret: conf.LinkedInSecret, + RedirectURL: conf.LinkedInRedirectURL, Scopes: []string{"openid", "profile", "w_member_social"}, Endpoint: linkedin.Endpoint, } @@ -133,9 +133,9 @@ func LinkedInCreds(ctx context.Context, args config.Args) (string, string, error return "", "", errs } - secrets.LinkedInAccessToken = oauthAccessToken - secrets.LinkedInPersonID = oauthPersonID - return oauthPersonID, oauthAccessToken, secrets.WriteToDisk(args.SecretsConfigPath) + conf.LinkedInAccessToken = oauthAccessToken + conf.LinkedInPersonID = oauthPersonID + return oauthPersonID, oauthAccessToken, conf.WriteToDisk(args.ConfigPath) } func openURLInFirefox(browser, url string) error { diff --git a/internal/platforms/mastodon/mastodon.go b/internal/platforms/mastodon/mastodon.go index f52f905..ad4733b 100644 --- a/internal/platforms/mastodon/mastodon.go +++ b/internal/platforms/mastodon/mastodon.go @@ -39,12 +39,12 @@ func Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) newCtx, cancel := context.WithTimeout(ctx, mastodonTimeout) defer cancel() - req, err := http.NewRequestWithContext(newCtx, "POST", args.Secrets.MastodonURL, bytes.NewBuffer(payloadBytes)) + req, err := http.NewRequestWithContext(newCtx, "POST", args.Config.MastodonURL, bytes.NewBuffer(payloadBytes)) if err != nil { return fmt.Errorf("failed to create request: %w", err) } - req.Header.Set("Authorization", "Bearer "+args.Secrets.MastodonAccessToken) + req.Header.Set("Authorization", "Bearer "+args.Config.MastodonAccessToken) req.Header.Set("Content-Type", "application/json") client := &http.Client{} |
