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
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+14
-2
@@ -29,6 +29,7 @@ type User struct {
|
||||
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,8 +105,12 @@ const (
|
||||
|
||||
type Notifications struct {
|
||||
NotificationsTemplate
|
||||
NotificationsSettings
|
||||
}
|
||||
|
||||
type NotificationsSettings struct {
|
||||
PgpKey any `json:"pgpKey,omitempty"`
|
||||
DiscordID string `json:"discordId,omitempty"`
|
||||
DiscordIDs []string `json:"discordIds,omitempty"`
|
||||
PushbulletAccessToken any `json:"pushbulletAccessToken,omitempty"`
|
||||
PushoverApplicationToken any `json:"pushoverApplicationToken,omitempty"`
|
||||
PushoverUserKey any `json:"pushoverUserKey,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user