diff --git a/internal/client/client.go b/internal/client/client.go index b4ea7ff..b47bac6 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -79,10 +79,9 @@ func (g *Client) DownloadMedia(url, path string) error { defer response.Body.Close() if response.StatusCode != http.StatusOK { - return fmt.Errorf( - "did not receive an OK response from the GoToSocial server: got %d", - response.StatusCode, - ) + return BadStatusCodeError{ + statusCode: response.StatusCode, + } } file, err := os.Create(path) diff --git a/internal/client/errors.go b/internal/client/errors.go index 53ace80..24c729c 100644 --- a/internal/client/errors.go +++ b/internal/client/errors.go @@ -31,6 +31,17 @@ func (e ResponseError) Error() string { ) } +type BadStatusCodeError struct { + statusCode int +} + +func (e BadStatusCodeError) Error() string { + return fmt.Sprintf( + "did not receive an OK response from the GoToSocial server: got %d", + e.statusCode, + ) +} + type Error struct { message string } diff --git a/internal/executor/mute.go b/internal/executor/mute.go index 121b1a4..a3d4698 100644 --- a/internal/executor/mute.go +++ b/internal/executor/mute.go @@ -68,6 +68,7 @@ func (m *MuteExecutor) muteStatus(gtsClient *client.Client) error { for _, mention := range status.Mentions { if mention.ID == myAccountID { canMute = true + break } } diff --git a/internal/executor/unmute.go b/internal/executor/unmute.go index 17a082d..6b678b6 100644 --- a/internal/executor/unmute.go +++ b/internal/executor/unmute.go @@ -63,6 +63,7 @@ func (m *UnmuteExecutor) unmuteStatus(gtsClient *client.Client) error { for _, mention := range status.Mentions { if mention.ID == myAccountID { canUnmute = true + break } } diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 0ec5951..ff397d6 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -133,11 +133,11 @@ func (p Printer) fullDisplayNameFormat(displayName, acct string) string { } func (p Printer) formatDate(date time.Time) string { - return date.Local().Format(dateFormat) + return date.Local().Format(dateFormat) //nolint:gosmopolitan } func (p Printer) formatDateTime(date time.Time) string { - return date.Local().Format(dateTimeFormat) + return date.Local().Format(dateTimeFormat) //nolint:gosmopolitan } func (p Printer) print(text string) { diff --git a/internal/utilities/utilities.go b/internal/utilities/utilities.go index 3c66121..600b3f2 100644 --- a/internal/utilities/utilities.go +++ b/internal/utilities/utilities.go @@ -50,7 +50,7 @@ func OpenLink(browser, url string) error { cmd := strings.Split(browser, " ") cmd = append(cmd, url) - command := exec.Command(cmd[0], cmd[1:]...) + command := exec.Command(cmd[0], cmd[1:]...) //nolint:gosec if err := command.Start(); err != nil { return fmt.Errorf("received an error after starting the program to view the link: %w", err)