mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-10 04:10:10 +00:00
jellyseer: auto-null NotifTypes field
changed to a pointer so it can be nil-ed, and an Empty() receiver method is used to check if it needs it in ApplyNotificationsTemplateToUser.
This commit is contained in:
parent
a97bccc88f
commit
769a7c45da
@ -356,6 +356,9 @@ func (js *Jellyseerr) GetNotificationPreferencesByID(jellyseerrID int64) (Notifi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (js *Jellyseerr) ApplyNotificationsTemplateToUser(jfID string, tmpl NotificationsTemplate) error {
|
func (js *Jellyseerr) ApplyNotificationsTemplateToUser(jfID string, tmpl NotificationsTemplate) error {
|
||||||
|
if tmpl.NotifTypes.Empty() {
|
||||||
|
tmpl.NotifTypes = nil
|
||||||
|
}
|
||||||
u, err := js.MustGetUser(jfID)
|
u, err := js.MustGetUser(jfID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -81,6 +81,10 @@ type NotificationTypes struct {
|
|||||||
Webpush int64 `json:"webpush,omitempty"`
|
Webpush int64 `json:"webpush,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nt *NotificationTypes) Empty() bool {
|
||||||
|
return nt.Discord == 0 && nt.Email == 0 && nt.Pushbullet == 0 && nt.Pushover == 0 && nt.Slack == 0 && nt.Telegram == 0 && nt.Webhook == 0 && nt.Webpush == 0
|
||||||
|
}
|
||||||
|
|
||||||
type NotificationsField string
|
type NotificationsField string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -109,5 +113,5 @@ type NotificationsTemplate struct {
|
|||||||
TelegramEnabled bool `json:"telegramEnabled,omitempty"`
|
TelegramEnabled bool `json:"telegramEnabled,omitempty"`
|
||||||
TelegramSendSilently any `json:"telegramSendSilently,omitempty"`
|
TelegramSendSilently any `json:"telegramSendSilently,omitempty"`
|
||||||
WebPushEnabled bool `json:"webPushEnabled,omitempty"`
|
WebPushEnabled bool `json:"webPushEnabled,omitempty"`
|
||||||
NotifTypes NotificationTypes `json:"notificationTypes,omitempty"`
|
NotifTypes *NotificationTypes `json:"notificationTypes,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user