checkpoint
This commit is contained in:
parent
e49da231d4
commit
1cd451ae72
6 changed files with 19 additions and 7 deletions
|
@ -79,10 +79,9 @@ func (g *Client) DownloadMedia(url, path string) error {
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
if response.StatusCode != http.StatusOK {
|
if response.StatusCode != http.StatusOK {
|
||||||
return fmt.Errorf(
|
return BadStatusCodeError{
|
||||||
"did not receive an OK response from the GoToSocial server: got %d",
|
statusCode: response.StatusCode,
|
||||||
response.StatusCode,
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := os.Create(path)
|
file, err := os.Create(path)
|
||||||
|
|
|
@ -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 {
|
type Error struct {
|
||||||
message string
|
message string
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ func (m *MuteExecutor) muteStatus(gtsClient *client.Client) error {
|
||||||
for _, mention := range status.Mentions {
|
for _, mention := range status.Mentions {
|
||||||
if mention.ID == myAccountID {
|
if mention.ID == myAccountID {
|
||||||
canMute = true
|
canMute = true
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ func (m *UnmuteExecutor) unmuteStatus(gtsClient *client.Client) error {
|
||||||
for _, mention := range status.Mentions {
|
for _, mention := range status.Mentions {
|
||||||
if mention.ID == myAccountID {
|
if mention.ID == myAccountID {
|
||||||
canUnmute = true
|
canUnmute = true
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,11 +133,11 @@ func (p Printer) fullDisplayNameFormat(displayName, acct string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) formatDate(date time.Time) 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 {
|
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) {
|
func (p Printer) print(text string) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ func OpenLink(browser, url string) error {
|
||||||
cmd := strings.Split(browser, " ")
|
cmd := strings.Split(browser, " ")
|
||||||
cmd = append(cmd, url)
|
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 {
|
if err := command.Start(); err != nil {
|
||||||
return fmt.Errorf("received an error after starting the program to view the link: %w", err)
|
return fmt.Errorf("received an error after starting the program to view the link: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue