76 lines
2.1 KiB
Go
Raw Normal View History

2021-05-22 18:20:18 -04:00
package scraper
import (
"database/sql/driver"
"errors"
"strings"
2021-05-22 18:20:18 -04:00
)
var ERR_NO_TWEET = errors.New("Empty tweet")
type TweetID int64
2021-05-22 18:20:18 -04:00
type CommaSeparatedList []string
func (l *CommaSeparatedList) Scan(src interface{}) error {
*l = CommaSeparatedList{}
2023-06-03 09:17:12 -03:00
switch src := src.(type) {
case string:
2023-06-03 09:17:12 -03:00
for _, v := range strings.Split(src, ",") {
if v != "" {
*l = append(*l, v)
}
}
default:
panic("Should be a string")
}
return nil
}
func (l CommaSeparatedList) Value() (driver.Value, error) {
return strings.Join(l, ","), nil
}
2021-05-22 18:20:18 -04:00
type Tweet struct {
2023-08-13 15:57:58 -03:00
ID TweetID `db:"id"`
Text string `db:"text"`
IsExpandable bool `db:"is_expandable"`
PostedAt Timestamp `db:"posted_at"`
NumLikes int `db:"num_likes"`
NumRetweets int `db:"num_retweets"`
NumReplies int `db:"num_replies"`
NumQuoteTweets int `db:"num_quote_tweets"`
InReplyToID TweetID `db:"in_reply_to_id"`
QuotedTweetID TweetID `db:"quoted_tweet_id"`
2021-05-22 18:20:18 -04:00
2023-08-13 15:57:58 -03:00
UserID UserID `db:"user_id"`
User *User `db:"user"`
// For processing tombstones
UserHandle UserHandle
in_reply_to_user_handle UserHandle
in_reply_to_user_id UserID
Images []Image
Videos []Video
2021-12-12 16:42:32 -08:00
Urls []Url
Polls []Poll
Mentions CommaSeparatedList `db:"mentions"`
ReplyMentions CommaSeparatedList `db:"reply_mentions"`
Hashtags CommaSeparatedList `db:"hashtags"`
2022-11-24 18:57:42 -05:00
// TODO get-rid-of-redundant-spaces: Might be good to get rid of `Spaces`. Only used in APIv1 I think.
2022-11-24 18:57:42 -05:00
// A first-step would be to delete the Spaces after pulling them out of a Tweet into the Trove
// in ToTweetTrove. Then they will only be getting saved once rather than twice.
2022-11-24 19:01:30 -05:00
Spaces []Space
SpaceID SpaceID `db:"space_id"`
2021-08-07 16:51:38 -07:00
TombstoneType string `db:"tombstone_type"`
2023-08-29 12:27:31 -03:00
TombstoneText string `db:"tombstone_text"`
IsStub bool `db:"is_stub"`
2021-11-06 13:37:46 -07:00
IsLikedByCurrentUser bool `db:"is_liked_by_current_user"`
IsContentDownloaded bool `db:"is_content_downloaded"`
IsConversationScraped bool `db:"is_conversation_scraped"`
LastScrapedAt Timestamp `db:"last_scraped_at"`
2021-05-22 18:20:18 -04:00
}