2025-02-14 15:54:36 -08:00
|
|
|
package persistence
|
2024-08-25 16:27:49 -07:00
|
|
|
|
|
|
|
type NotificationID string
|
|
|
|
|
2024-08-25 22:48:09 -07:00
|
|
|
type NotificationType int
|
|
|
|
|
|
|
|
const (
|
2024-08-28 19:20:29 -07:00
|
|
|
// ActionUserID is who "liked" it, Action[Re]TweetID is most recent [re]tweet they "liked".
|
|
|
|
// Can have either many Users "liking" one [re]tweet, or many 1 User "liking" many [re]tweets.
|
2025-02-15 14:30:47 -08:00
|
|
|
// The "liked" items can be a mix of Tweets and Retweets.
|
2024-08-28 19:20:29 -07:00
|
|
|
NOTIFICATION_TYPE_LIKE NotificationType = iota + 1
|
|
|
|
|
|
|
|
// ActionUserID is who retweeted it, Action[Re]TweetID is your [re]tweet they retweeted.
|
|
|
|
// Can have either many Users to one [re]tweet, or many [Re]Tweets from 1 User.
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_RETWEET
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionUserID is who quote-tweeted you. ActionTweetID is their tweet. ActionRetweet is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_QUOTE_TWEET
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionUserID is who replied to you. ActionTweetID is their tweet. ActionRetweet is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_REPLY
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionUserID is who followed you. Everything else is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_FOLLOW
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionTweetID is their tweet. ActionUserID and ActionRetweetID are empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_MENTION
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionUserID is who is live. Everything else is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_USER_IS_LIVE
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionTweetID is the tweet with the poll. Everything else is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_POLL_ENDED
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// Everything is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_LOGIN
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionTweetID is the new pinned post. Everything else is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_COMMUNITY_PINNED_POST
|
2024-08-28 19:20:29 -07:00
|
|
|
|
|
|
|
// ActionTweetID is the recommended post. Everything else is empty
|
2024-08-25 22:48:09 -07:00
|
|
|
NOTIFICATION_TYPE_RECOMMENDED_POST
|
|
|
|
)
|
|
|
|
|
2024-08-25 16:27:49 -07:00
|
|
|
type Notification struct {
|
2024-08-28 19:20:29 -07:00
|
|
|
ID NotificationID `db:"id"`
|
|
|
|
Type NotificationType `db:"type"`
|
|
|
|
SentAt Timestamp `db:"sent_at"`
|
|
|
|
SortIndex int64 `db:"sort_index"`
|
|
|
|
UserID UserID `db:"user_id"` // recipient of the notification
|
2024-08-25 16:27:49 -07:00
|
|
|
|
2024-08-25 22:54:18 -07:00
|
|
|
ActionUserID UserID `db:"action_user_id"`
|
|
|
|
ActionTweetID TweetID `db:"action_tweet_id"`
|
|
|
|
ActionRetweetID TweetID `db:"action_retweet_id"`
|
2024-08-25 16:27:49 -07:00
|
|
|
|
2024-08-28 19:22:09 -07:00
|
|
|
// Used for "multiple" notifs, like "user liked multiple tweets"
|
|
|
|
HasDetail bool `db:"has_detail"`
|
|
|
|
LastScrapedAt Timestamp `db:"last_scraped_at"`
|
|
|
|
|
2024-08-28 19:20:29 -07:00
|
|
|
TweetIDs []TweetID
|
|
|
|
UserIDs []UserID
|
|
|
|
RetweetIDs []TweetID
|
2024-08-25 16:27:49 -07:00
|
|
|
}
|