mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-08 16:33:17 -06:00
convert statuses.visibility and notifications.notification_type columns from type string -> int for performance / space savings
This commit is contained in:
parent
301543616b
commit
759df1240a
21 changed files with 586 additions and 84 deletions
|
|
@ -224,7 +224,7 @@ func DefaultInteractionPolicyFor(v Visibility) *InteractionPolicy {
|
|||
case VisibilityDirect:
|
||||
return DefaultInteractionPolicyDirect()
|
||||
default:
|
||||
panic("visibility " + v + " not recognized")
|
||||
panic("invalid visibility")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,20 +34,51 @@ type Notification struct {
|
|||
Read *bool `bun:",nullzero,notnull,default:false"` // Notification has been seen/read
|
||||
}
|
||||
|
||||
// NotificationType describes the reason/type of this notification.
|
||||
type NotificationType string
|
||||
// NotificationType describes the
|
||||
// reason/type of this notification.
|
||||
type NotificationType int
|
||||
|
||||
// Notification Types
|
||||
const (
|
||||
NotificationFollow NotificationType = "follow" // NotificationFollow -- someone followed you
|
||||
NotificationFollowRequest NotificationType = "follow_request" // NotificationFollowRequest -- someone requested to follow you
|
||||
NotificationMention NotificationType = "mention" // NotificationMention -- someone mentioned you in their status
|
||||
NotificationReblog NotificationType = "reblog" // NotificationReblog -- someone boosted one of your statuses
|
||||
NotificationFave NotificationType = "favourite" // NotificationFave -- someone faved/liked one of your statuses
|
||||
NotificationPoll NotificationType = "poll" // NotificationPoll -- a poll you voted in or created has ended
|
||||
NotificationStatus NotificationType = "status" // NotificationStatus -- someone you enabled notifications for has posted a status.
|
||||
NotificationSignup NotificationType = "admin.sign_up" // NotificationSignup -- someone has submitted a new account sign-up to the instance.
|
||||
NotificationPendingFave NotificationType = "pending.favourite" // Someone has faved a status of yours, which requires approval by you.
|
||||
NotificationPendingReply NotificationType = "pending.reply" // Someone has replied to a status of yours, which requires approval by you.
|
||||
NotificationPendingReblog NotificationType = "pending.reblog" // Someone has boosted a status of yours, which requires approval by you.
|
||||
// Notification Types
|
||||
NotificationFollow NotificationType = 1 // NotificationFollow -- someone followed you
|
||||
NotificationFollowRequest NotificationType = 2 // NotificationFollowRequest -- someone requested to follow you
|
||||
NotificationMention NotificationType = 3 // NotificationMention -- someone mentioned you in their status
|
||||
NotificationReblog NotificationType = 4 // NotificationReblog -- someone boosted one of your statuses
|
||||
NotificationFave NotificationType = 5 // NotificationFave -- someone faved/liked one of your statuses
|
||||
NotificationPoll NotificationType = 6 // NotificationPoll -- a poll you voted in or created has ended
|
||||
NotificationStatus NotificationType = 7 // NotificationStatus -- someone you enabled notifications for has posted a status.
|
||||
NotificationSignup NotificationType = 8 // NotificationSignup -- someone has submitted a new account sign-up to the instance.
|
||||
NotificationPendingFave NotificationType = 9 // Someone has faved a status of yours, which requires approval by you.
|
||||
NotificationPendingReply NotificationType = 10 // Someone has replied to a status of yours, which requires approval by you.
|
||||
NotificationPendingReblog NotificationType = 11 // Someone has boosted a status of yours, which requires approval by you.
|
||||
)
|
||||
|
||||
// String returns a stringified, frontend API compatible form of NotificationType.
|
||||
func (t NotificationType) String() string {
|
||||
switch t {
|
||||
case NotificationFollow:
|
||||
return "follow"
|
||||
case NotificationFollowRequest:
|
||||
return "follow_request"
|
||||
case NotificationMention:
|
||||
return "mention"
|
||||
case NotificationReblog:
|
||||
return "reblog"
|
||||
case NotificationFave:
|
||||
return "favourite"
|
||||
case NotificationPoll:
|
||||
return "poll"
|
||||
case NotificationStatus:
|
||||
return "status"
|
||||
case NotificationSignup:
|
||||
return "admin.sign_up"
|
||||
case NotificationPendingFave:
|
||||
return "pending.favourite"
|
||||
case NotificationPendingReply:
|
||||
return "pending.reply"
|
||||
case NotificationPendingReblog:
|
||||
return "pending.reblog"
|
||||
default:
|
||||
panic("invalid notification type")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,27 +263,58 @@ type StatusToEmoji struct {
|
|||
Emoji *Emoji `bun:"rel:belongs-to"`
|
||||
}
|
||||
|
||||
// Visibility represents the visibility granularity of a status.
|
||||
type Visibility string
|
||||
// Visibility represents the
|
||||
// visibility granularity of a status.
|
||||
type Visibility int
|
||||
|
||||
const (
|
||||
// VisibilityNone means nobody can see this.
|
||||
// It's only used for web status visibility.
|
||||
VisibilityNone Visibility = "none"
|
||||
// VisibilityPublic means this status will be visible to everyone on all timelines.
|
||||
VisibilityPublic Visibility = "public"
|
||||
// VisibilityUnlocked means this status will be visible to everyone, but will only show on home timeline to followers, and in lists.
|
||||
VisibilityUnlocked Visibility = "unlocked"
|
||||
VisibilityNone Visibility = 1
|
||||
|
||||
// VisibilityPublic means this status will
|
||||
// be visible to everyone on all timelines.
|
||||
VisibilityPublic Visibility = 2
|
||||
|
||||
// VisibilityUnlocked means this status will be visible to everyone,
|
||||
// but will only show on home timeline to followers, and in lists.
|
||||
VisibilityUnlocked Visibility = 3
|
||||
|
||||
// VisibilityFollowersOnly means this status is viewable to followers only.
|
||||
VisibilityFollowersOnly Visibility = "followers_only"
|
||||
// VisibilityMutualsOnly means this status is visible to mutual followers only.
|
||||
VisibilityMutualsOnly Visibility = "mutuals_only"
|
||||
// VisibilityDirect means this status is visible only to mentioned recipients.
|
||||
VisibilityDirect Visibility = "direct"
|
||||
VisibilityFollowersOnly Visibility = 4
|
||||
|
||||
// VisibilityMutualsOnly means this status
|
||||
// is visible to mutual followers only.
|
||||
VisibilityMutualsOnly Visibility = 5
|
||||
|
||||
// VisibilityDirect means this status is
|
||||
// visible only to mentioned recipients.
|
||||
VisibilityDirect Visibility = 6
|
||||
|
||||
// VisibilityDefault is used when no other setting can be found.
|
||||
VisibilityDefault Visibility = VisibilityUnlocked
|
||||
)
|
||||
|
||||
// String returns a stringified, frontend API compatible form of Visibility.
|
||||
func (v Visibility) String() string {
|
||||
switch v {
|
||||
case VisibilityNone:
|
||||
return "none"
|
||||
case VisibilityPublic:
|
||||
return "public"
|
||||
case VisibilityUnlocked:
|
||||
return "unlocked"
|
||||
case VisibilityFollowersOnly:
|
||||
return "followers_only"
|
||||
case VisibilityMutualsOnly:
|
||||
return "mutuals_only"
|
||||
case VisibilityDirect:
|
||||
return "direct"
|
||||
default:
|
||||
panic("invalid visibility")
|
||||
}
|
||||
}
|
||||
|
||||
// Content models the simple string content
|
||||
// of a status along with its ContentMap,
|
||||
// which contains content entries keyed by
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue