Add notification type for update notifications

Not used yet
This commit is contained in:
Vyr Cossont 2024-12-28 14:38:54 -08:00
parent 6ed26e0a93
commit 053bad3ca1
4 changed files with 9 additions and 5 deletions

View file

@ -56,7 +56,8 @@ type Notification struct {
NotificationPendingReply NotificationType = 10 // NotificationPendingReply -- Someone has replied to a status of yours, which requires approval by you.
NotificationPendingReblog NotificationType = 11 // NotificationPendingReblog -- Someone has boosted a status of yours, which requires approval by you.
NotificationAdminReport NotificationType = 12 // NotificationAdminReport -- someone has submitted a new report to the instance.
NotificationTypeNumValues NotificationType = 13 // NotificationTypeNumValues -- 1 + number of max notification type
NotificationUpdate NotificationType = 13
NotificationTypeNumValues NotificationType = 14 // NotificationTypeNumValues -- 1 + number of max notification type
)
// String returns a stringified, frontend API compatible form of NotificationType.
@ -86,6 +87,8 @@ func (t NotificationType) String() string {
return "pending.reblog"
case NotificationAdminReport:
return "admin.report"
case NotificationUpdate:
return "update"
default:
panic("invalid notification type")
}
@ -118,6 +121,8 @@ func ParseNotificationType(in string) NotificationType {
return NotificationPendingReblog
case "admin.report":
return NotificationAdminReport
case "update":
return NotificationUpdate
default:
return NotificationUnknown
}

View file

@ -76,8 +76,7 @@ func alertsToNotificationFlags(alerts *apimodel.WebPushSubscriptionAlerts) gtsmo
n.Set(gtsmodel.NotificationReblog, alerts.Reblog)
n.Set(gtsmodel.NotificationPoll, alerts.Poll)
n.Set(gtsmodel.NotificationStatus, alerts.Status)
// TODO: (Vyr) handle NotificationUpdate when edit patch is merged
//n.Set(gtsmodel.NotificationUpdate, alerts.Update)
n.Set(gtsmodel.NotificationUpdate, alerts.Update)
n.Set(gtsmodel.NotificationAdminSignup, alerts.AdminSignup)
n.Set(gtsmodel.NotificationAdminReport, alerts.AdminReport)
n.Set(gtsmodel.NotificationPendingFave, alerts.PendingFavourite)

View file

@ -2964,7 +2964,7 @@ func (c *Converter) WebPushSubscriptionToAPIWebPushSubscription(
Reblog: subscription.NotificationFlags.Get(gtsmodel.NotificationReblog),
Poll: subscription.NotificationFlags.Get(gtsmodel.NotificationPoll),
Status: subscription.NotificationFlags.Get(gtsmodel.NotificationStatus),
Update: false, // TODO: (Vyr) handle NotificationUpdate when edit patch is merged
Update: subscription.NotificationFlags.Get(gtsmodel.NotificationUpdate),
AdminSignup: subscription.NotificationFlags.Get(gtsmodel.NotificationAdminSignup),
AdminReport: subscription.NotificationFlags.Get(gtsmodel.NotificationAdminReport),
PendingFavourite: subscription.NotificationFlags.Get(gtsmodel.NotificationPendingFave),

View file

@ -3603,7 +3603,7 @@ func NewTestWebPushSubscriptions() map[string]*gtsmodel.WebPushSubscription {
gtsmodel.NotificationReblog,
gtsmodel.NotificationPoll,
gtsmodel.NotificationStatus,
// TODO: (Vyr) add NotificationUpdate when edit patch is merged
gtsmodel.NotificationUpdate,
gtsmodel.NotificationAdminSignup,
gtsmodel.NotificationAdminReport,
gtsmodel.NotificationPendingFave,