seerr: fix discord ID setting
APi change, discordId is now discordIds (an array).
This commit is contained in:
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -45,7 +46,7 @@ func (app *appContext) SynchronizeJellyseerrUser(jfID string) {
|
|||||||
}
|
}
|
||||||
if discordEnabled {
|
if discordEnabled {
|
||||||
dcUser, ok := app.storage.GetDiscordKey(jfID)
|
dcUser, ok := app.storage.GetDiscordKey(jfID)
|
||||||
if ok && dcUser.ID != "" && notif.DiscordID != dcUser.ID {
|
if ok && dcUser.ID != "" && !slices.Contains(notif.DiscordIDs, dcUser.ID) {
|
||||||
contactMethods[jellyseerr.FieldDiscord] = dcUser.ID
|
contactMethods[jellyseerr.FieldDiscord] = dcUser.ID
|
||||||
contactMethods[jellyseerr.FieldDiscordEnabled] = dcUser.Contact
|
contactMethods[jellyseerr.FieldDiscordEnabled] = dcUser.Contact
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,6 +425,13 @@ func (js *Jellyseerr) ApplyNotificationsTemplateToUser(jfID string, tmpl Notific
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (js *Jellyseerr) ModifyNotifications(jfID string, conf map[NotificationsField]any) error {
|
func (js *Jellyseerr) ModifyNotifications(jfID string, conf map[NotificationsField]any) error {
|
||||||
|
// Fix for API change: discord IDs are now stored as an array rather than as a single ID string
|
||||||
|
if v, ok := conf[FieldDiscord]; ok {
|
||||||
|
switch v.(type) {
|
||||||
|
case string:
|
||||||
|
conf[FieldDiscord] = []string{v.(string)}
|
||||||
|
}
|
||||||
|
}
|
||||||
u, err := js.getUser(jfID)
|
u, err := js.getUser(jfID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+14
-2
@@ -29,6 +29,7 @@ type User struct {
|
|||||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||||
RequestCount int64 `json:"requestCount,omitempty"`
|
RequestCount int64 `json:"requestCount,omitempty"`
|
||||||
DisplayName string `json:"displayName,omitempty"`
|
DisplayName string `json:"displayName,omitempty"`
|
||||||
|
Settings *UserSettings `json:"settings,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u User) Name() string {
|
func (u User) Name() string {
|
||||||
@@ -44,6 +45,13 @@ func (u User) Name() string {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fields have been omitted (those I know not the type of)
|
||||||
|
type UserSettings struct {
|
||||||
|
ID int64 `json:"id,omitempty"`
|
||||||
|
Locale string `json:"locale,omitempty"`
|
||||||
|
NotificationsSettings
|
||||||
|
}
|
||||||
|
|
||||||
type UserTemplate struct {
|
type UserTemplate struct {
|
||||||
Permissions Permissions `json:"permissions,omitempty"`
|
Permissions Permissions `json:"permissions,omitempty"`
|
||||||
MovieQuotaLimit any `json:"movieQuotaLimit,omitempty"`
|
MovieQuotaLimit any `json:"movieQuotaLimit,omitempty"`
|
||||||
@@ -88,7 +96,7 @@ type NotificationTypes struct {
|
|||||||
type NotificationsField string
|
type NotificationsField string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FieldDiscord NotificationsField = "discordId"
|
FieldDiscord NotificationsField = "discordIds"
|
||||||
FieldTelegram NotificationsField = "telegramChatId"
|
FieldTelegram NotificationsField = "telegramChatId"
|
||||||
FieldEmailEnabled NotificationsField = "emailEnabled"
|
FieldEmailEnabled NotificationsField = "emailEnabled"
|
||||||
FieldDiscordEnabled NotificationsField = "discordEnabled"
|
FieldDiscordEnabled NotificationsField = "discordEnabled"
|
||||||
@@ -97,8 +105,12 @@ const (
|
|||||||
|
|
||||||
type Notifications struct {
|
type Notifications struct {
|
||||||
NotificationsTemplate
|
NotificationsTemplate
|
||||||
|
NotificationsSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
type NotificationsSettings struct {
|
||||||
PgpKey any `json:"pgpKey,omitempty"`
|
PgpKey any `json:"pgpKey,omitempty"`
|
||||||
DiscordID string `json:"discordId,omitempty"`
|
DiscordIDs []string `json:"discordIds,omitempty"`
|
||||||
PushbulletAccessToken any `json:"pushbulletAccessToken,omitempty"`
|
PushbulletAccessToken any `json:"pushbulletAccessToken,omitempty"`
|
||||||
PushoverApplicationToken any `json:"pushoverApplicationToken,omitempty"`
|
PushoverApplicationToken any `json:"pushoverApplicationToken,omitempty"`
|
||||||
PushoverUserKey any `json:"pushoverUserKey,omitempty"`
|
PushoverUserKey any `json:"pushoverUserKey,omitempty"`
|
||||||
|
|||||||
Reference in New Issue
Block a user