Add 'tombstone' search filter and search bar filter argument for 'followed_by'

This commit is contained in:
Alessio 2024-03-22 21:34:02 -07:00
parent 125445671d
commit 4e0efd8cf9

View File

@ -138,6 +138,7 @@ type Cursor struct {
FollowedByUserHandle scraper.UserHandle // Either tweeted or retweeted by users followed by this user FollowedByUserHandle scraper.UserHandle // Either tweeted or retweeted by users followed by this user
SinceTimestamp scraper.Timestamp SinceTimestamp scraper.Timestamp
UntilTimestamp scraper.Timestamp UntilTimestamp scraper.Timestamp
TombstoneType string
FilterLinks Filter FilterLinks Filter
FilterImages Filter FilterImages Filter
FilterVideos Filter FilterVideos Filter
@ -315,10 +316,14 @@ func (c *Cursor) apply_token(token string) error {
c.FilterRetweets = NONE // Clear the "exclude retweets" filter set by default in NewCursor c.FilterRetweets = NONE // Clear the "exclude retweets" filter set by default in NewCursor
case "liked_by": case "liked_by":
c.LikedByUserHandle = scraper.UserHandle(parts[1]) c.LikedByUserHandle = scraper.UserHandle(parts[1])
case "followed_by":
c.FollowedByUserHandle = scraper.UserHandle(parts[1])
case "since": case "since":
c.SinceTimestamp.Time, err = time.Parse("2006-01-02", parts[1]) c.SinceTimestamp.Time, err = time.Parse("2006-01-02", parts[1])
case "until": case "until":
c.UntilTimestamp.Time, err = time.Parse("2006-01-02", parts[1]) c.UntilTimestamp.Time, err = time.Parse("2006-01-02", parts[1])
case "tombstone":
c.TombstoneType = parts[1]
case "filter": case "filter":
switch parts[1] { switch parts[1] {
case "links": case "links":
@ -412,6 +417,14 @@ func (p Profile) NextPage(c Cursor, current_user_id scraper.UserID) (Feed, error
bind_values = append(bind_values, c.UntilTimestamp) bind_values = append(bind_values, c.UntilTimestamp)
} }
// Tombstone filter
if c.TombstoneType == "true" {
where_clauses = append(where_clauses, "tombstone_type != 0")
} else if c.TombstoneType != "" {
where_clauses = append(where_clauses, "tombstone_type = (select rowid from tombstone_types where short_name like ?)")
bind_values = append(bind_values, c.TombstoneType)
}
// Media filters // Media filters
switch c.FilterLinks { switch c.FilterLinks {
case REQUIRE: case REQUIRE: