summaryrefslogtreecommitdiff
path: root/internal/platforms
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-11 22:07:51 +0200
committerPaul Buetow <paul@buetow.org>2024-12-11 22:07:51 +0200
commit1dca76e728a70b70ee8001c87407acf962e731cd (patch)
tree4636d5b8769595de135bca8977b951d0a570da48 /internal/platforms
parenta5529938536f7a530f0c55e5a82b16a4c80af5b4 (diff)
refactor a bit again
Diffstat (limited to 'internal/platforms')
-rw-r--r--internal/platforms/linkedin/linkedin.go7
-rw-r--r--internal/platforms/linkedin/oauth2/oauth2.go10
-rw-r--r--internal/platforms/linkedin/preview.go6
-rw-r--r--internal/platforms/mastodon/mastodon.go2
-rw-r--r--internal/platforms/platform.go2
5 files changed, 12 insertions, 15 deletions
diff --git a/internal/platforms/linkedin/linkedin.go b/internal/platforms/linkedin/linkedin.go
index b960c01..85b95af 100644
--- a/internal/platforms/linkedin/linkedin.go
+++ b/internal/platforms/linkedin/linkedin.go
@@ -25,9 +25,7 @@ const linkedInTimeout = 10 * time.Second
func Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) error {
err := post(ctx, args, sizeLimit, en)
if errors.Is(err, errUnauthorized) {
- if _, err = colour.Infoln(err, "=> trying to refresh LinkedIn access token"); err != nil {
- return err
- }
+ colour.Infoln(err, "=> trying to refresh LinkedIn access token")
args.Secrets.LinkedInAccessToken = "" // Reset the token
return post(ctx, args, sizeLimit, en)
}
@@ -36,8 +34,7 @@ func Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry)
func post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) error {
if args.DryRun {
- _, err := colour.Infoln("Not posting", en, "to LinkedIn as dry-run enabled")
- return err
+ colour.Infoln("Not posting", en, "to LinkedIn as dry-run enabled")
}
timeout := linkedInTimeout
diff --git a/internal/platforms/linkedin/oauth2/oauth2.go b/internal/platforms/linkedin/oauth2/oauth2.go
index f37e913..51beec9 100644
--- a/internal/platforms/linkedin/oauth2/oauth2.go
+++ b/internal/platforms/linkedin/oauth2/oauth2.go
@@ -72,7 +72,7 @@ func oauthCallbackHandler(w http.ResponseWriter, r *http.Request) {
defer close(errCh)
code := r.URL.Query().Get("code")
- _, _ = colour.Infoln("Exchanging OAuth2 token")
+ colour.Infoln("Exchanging OAuth2 token")
token, err := oauthConfig.Exchange(globalCtx, code)
if err != nil {
_, _ = w.Write([]byte(err.Error()))
@@ -110,7 +110,7 @@ func LinkedInCreds(ctx context.Context, args config.Args) (string, string, error
http.HandleFunc("/callback", oauthCallbackHandler)
http.HandleFunc("/up", upHandler)
- _, _ = colour.Infoln("Listening on http://localhost:8080 for LinkedIn OAuth2")
+ colour.Infoln("Listening on http://localhost:8080 for LinkedIn OAuth2")
go func() {
if err := http.ListenAndServe(":8080", nil); err != nil {
errCh <- err
@@ -139,7 +139,7 @@ func LinkedInCreds(ctx context.Context, args config.Args) (string, string, error
}
func openURLInFirefox(browser, url string) error {
- _, _ = colour.Infoln("Opening", url, "in", browser)
+ colour.Infoln("Opening", url, "in", browser)
switch runtime.GOOS {
case "windows":
cmd := exec.Command("cmd", "/C", "start", browser, url)
@@ -162,10 +162,10 @@ func WaitUntilURLIsReachable(url string) error {
resp, err := http.Get(url)
if err != nil {
- _, _ = colour.Infof("URL is not reachable: %v", err)
+ colour.Infof("URL is not reachable: %v", err)
fmt.Print("\n")
} else {
- _, _ = colour.Infof("URL is reachable: %s - Status Code: %d", url, resp.StatusCode)
+ colour.Infof("URL is reachable: %s - Status Code: %d", url, resp.StatusCode)
fmt.Print("\n")
resp.Body.Close()
return nil
diff --git a/internal/platforms/linkedin/preview.go b/internal/platforms/linkedin/preview.go
index b30ddf1..41b99a5 100644
--- a/internal/platforms/linkedin/preview.go
+++ b/internal/platforms/linkedin/preview.go
@@ -37,11 +37,11 @@ func NewPreview(ctx context.Context, args config.Args, urls []string) (preview,
if p.title, p.thumbnailURL, err = extractFromURL(ctx, urls[0]); err != nil {
if errors.Is(err, errNoTitleElementFound) || p.title == "" {
- _, _ = colour.Infoln("Setting title to", urls[0])
+ colour.Infoln("Setting title to", urls[0])
p.title = urls[0]
}
if errors.Is(err, errNoImageElementFound) {
- _, _ = colour.Infoln("URL", urls[0], "without any image, that's fine, though.")
+ colour.Infoln("URL", urls[0], "without any image, that's fine, though.")
}
if !errors.Is(err, errNoTitleElementFound) && !errors.Is(err, errNoImageElementFound) {
return p, err
@@ -52,7 +52,7 @@ func NewPreview(ctx context.Context, args config.Args, urls []string) (preview,
if p.thumbnailDownloadPath, err = p.DownloadImage(args.CacheDir); err != nil {
return p, err
}
- _, _ = colour.Infoln("Downloaded preview image to ", p.thumbnailDownloadPath)
+ colour.Infoln("Downloaded preview image to ", p.thumbnailDownloadPath)
}
return p, nil
}
diff --git a/internal/platforms/mastodon/mastodon.go b/internal/platforms/mastodon/mastodon.go
index abcbea9..938cf6f 100644
--- a/internal/platforms/mastodon/mastodon.go
+++ b/internal/platforms/mastodon/mastodon.go
@@ -23,7 +23,7 @@ func Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry)
return err
}
if args.DryRun {
- _, _ = colour.Infoln("Not posting", en, "to Mastodon as dry-run enabled")
+ colour.Infoln("Not posting", en, "to Mastodon as dry-run enabled")
return nil
}
if content, err = prompt.FileAction("Do you want to post this message to Mastodon?", content, en.Path); err != nil {
diff --git a/internal/platforms/platform.go b/internal/platforms/platform.go
index 3cf02c9..e5bbd22 100644
--- a/internal/platforms/platform.go
+++ b/internal/platforms/platform.go
@@ -39,7 +39,7 @@ func (p Platform) String() string {
}
func (p Platform) Post(ctx context.Context, args config.Args, sizeLimit int, en entry.Entry) (err error) {
- _, _ = colour.Infoln("Posting", en)
+ colour.Infoln("Posting", en)
switch p.String() {
case "mastodon":
err = mastodon.Post(ctx, args, sizeLimit, en)