From de8e7c69be0263f454388ebf9b00caffc4abfa05 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Wed, 10 Jun 2026 08:55:06 +0100 Subject: [PATCH] seerr: fix discord ID setting APi change, discordId is now discordIds (an array). --- jellyseerr-d.go | 3 +- jellyseerr/jellyseerr.go | 7 +++++ jellyseerr/models.go | 64 ++++++++++++++++++++++++---------------- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/jellyseerr-d.go b/jellyseerr-d.go index 4544350..e25e102 100644 --- a/jellyseerr-d.go +++ b/jellyseerr-d.go @@ -1,6 +1,7 @@ package main import ( + "slices" "strconv" "strings" "time" @@ -45,7 +46,7 @@ func (app *appContext) SynchronizeJellyseerrUser(jfID string) { } if discordEnabled { 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.FieldDiscordEnabled] = dcUser.Contact } diff --git a/jellyseerr/jellyseerr.go b/jellyseerr/jellyseerr.go index 2e35d6e..f781d93 100644 --- a/jellyseerr/jellyseerr.go +++ b/jellyseerr/jellyseerr.go @@ -425,6 +425,13 @@ func (js *Jellyseerr) ApplyNotificationsTemplateToUser(jfID string, tmpl Notific } 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) if err != nil { return err diff --git a/jellyseerr/models.go b/jellyseerr/models.go index 87648d8..8baa37e 100644 --- a/jellyseerr/models.go +++ b/jellyseerr/models.go @@ -10,25 +10,26 @@ const ( ) type User struct { - UserTemplate // Note: You can set this with User.UserTemplate = value. - UserType int64 `json:"userType,omitempty"` - Warnings []any `json:"warnings,omitempty"` - ID int64 `json:"id,omitempty"` - Email string `json:"email,omitempty"` - PlexUsername string `json:"plexUsername,omitempty"` - JellyfinUsername string `json:"jellyfinUsername,omitempty"` - Username string `json:"username,omitempty"` - RecoveryLinkExpirationDate any `json:"recoveryLinkExpirationDate,omitempty"` - PlexID string `json:"plexId,omitempty"` - JellyfinUserID string `json:"jellyfinUserId,omitempty"` - JellyfinDeviceID string `json:"jellyfinDeviceId,omitempty"` - JellyfinAuthToken string `json:"jellyfinAuthToken,omitempty"` - PlexToken string `json:"plexToken,omitempty"` - Avatar string `json:"avatar,omitempty"` - CreatedAt time.Time `json:"createdAt,omitempty"` - UpdatedAt time.Time `json:"updatedAt,omitempty"` - RequestCount int64 `json:"requestCount,omitempty"` - DisplayName string `json:"displayName,omitempty"` + UserTemplate // Note: You can set this with User.UserTemplate = value. + UserType int64 `json:"userType,omitempty"` + Warnings []any `json:"warnings,omitempty"` + ID int64 `json:"id,omitempty"` + Email string `json:"email,omitempty"` + PlexUsername string `json:"plexUsername,omitempty"` + JellyfinUsername string `json:"jellyfinUsername,omitempty"` + Username string `json:"username,omitempty"` + RecoveryLinkExpirationDate any `json:"recoveryLinkExpirationDate,omitempty"` + PlexID string `json:"plexId,omitempty"` + JellyfinUserID string `json:"jellyfinUserId,omitempty"` + JellyfinDeviceID string `json:"jellyfinDeviceId,omitempty"` + JellyfinAuthToken string `json:"jellyfinAuthToken,omitempty"` + PlexToken string `json:"plexToken,omitempty"` + Avatar string `json:"avatar,omitempty"` + CreatedAt time.Time `json:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` + RequestCount int64 `json:"requestCount,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Settings *UserSettings `json:"settings,omitempty"` } func (u User) Name() string { @@ -44,6 +45,13 @@ func (u User) Name() string { 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 { Permissions Permissions `json:"permissions,omitempty"` MovieQuotaLimit any `json:"movieQuotaLimit,omitempty"` @@ -88,7 +96,7 @@ type NotificationTypes struct { type NotificationsField string const ( - FieldDiscord NotificationsField = "discordId" + FieldDiscord NotificationsField = "discordIds" FieldTelegram NotificationsField = "telegramChatId" FieldEmailEnabled NotificationsField = "emailEnabled" FieldDiscordEnabled NotificationsField = "discordEnabled" @@ -97,12 +105,16 @@ const ( type Notifications struct { NotificationsTemplate - PgpKey any `json:"pgpKey,omitempty"` - DiscordID string `json:"discordId,omitempty"` - PushbulletAccessToken any `json:"pushbulletAccessToken,omitempty"` - PushoverApplicationToken any `json:"pushoverApplicationToken,omitempty"` - PushoverUserKey any `json:"pushoverUserKey,omitempty"` - TelegramChatID string `json:"telegramChatId,omitempty"` + NotificationsSettings +} + +type NotificationsSettings struct { + PgpKey any `json:"pgpKey,omitempty"` + DiscordIDs []string `json:"discordIds,omitempty"` + PushbulletAccessToken any `json:"pushbulletAccessToken,omitempty"` + PushoverApplicationToken any `json:"pushoverApplicationToken,omitempty"` + PushoverUserKey any `json:"pushoverUserKey,omitempty"` + TelegramChatID string `json:"telegramChatId,omitempty"` } type NotificationsTemplate struct {