Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
fix: retweets should not be deleted, not found unfavorites are not er…
Browse files Browse the repository at this point in the history
…rors
  • Loading branch information
Sergey Kibish committed Aug 7, 2021
1 parent c177763 commit 1523d77
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -141,7 +142,11 @@ func (c *Cleaner) remove(tweet anaconda.Tweet) error {

if !c.dryRun {
if err := c.twitter.UnFavorite(tweet.Id); err != nil {
return fmt.Errorf("failed to unfavorite the tweet %d: %w", tweet.Id, err)

// 144: No status found with that ID
if !strings.Contains(err.Error(), "144") {
return fmt.Errorf("failed to unfavorite the tweet %d: %w", tweet.Id, err)
}
}
}
}
Expand All @@ -154,9 +159,12 @@ func (c *Cleaner) remove(tweet anaconda.Tweet) error {
return fmt.Errorf("failed to unretweet the tweet %d: %w", tweet.Id, err)
}
}

// retweeted tweet can't be deleted
return nil
}

// if favorited/retweeted tweet is not a users tweet,
// if tweet is not a users tweet,
// return earlier
if tweet.User.Id != c.userID {
return nil
Expand Down

0 comments on commit 1523d77

Please sign in to comment.