mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[performance] convert enum strings to ints (#3558)
* convert statuses.visibility and notifications.notification_type columns from type string -> int for performance / space savings * fix test trying to compare string to int * fix instance count query using string literal instead of gtsmodel const type * ensure a default value is always set * also migrate the account settings and sin bin status tables * initialize maps outside loops and place into singular enum mapping creation func * use int16 for enum types * update sinbinstatus creation to be from a snapshot at initial creation * add snapshot of poll type at creation time
This commit is contained in:
@@ -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 enumType
|
||||
|
||||
// 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")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user