ThirdPartyServices: SetContactMethods for setting, enable/disable
replace AddContactMethods with a more generalised SetContactMethods, which can set (or leave alone) contact method addresses/names/ids and set (or leave alone) contact preferences. A little awkward to use, but works everywhere, and now a bunch of Jellyseerr integration features are present for Ombi (which they should've been anyway).
This commit is contained in:
+1
-9
@@ -246,16 +246,8 @@ type NotificationPref struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
func (ombi *Ombi) SetNotificationPrefs(user map[string]interface{}, discordID, telegramUser string) (result string, err error) {
|
||||
id := user["id"].(string)
|
||||
func (ombi *Ombi) SetNotificationPrefs(user map[string]interface{}, data []NotificationPref) (result string, err error) {
|
||||
url := fmt.Sprintf("%s/api/v1/Identity/NotificationPreferences", ombi.server)
|
||||
data := []NotificationPref{}
|
||||
if discordID != "" {
|
||||
data = append(data, NotificationPref{NotifAgentDiscord, id, discordID, true})
|
||||
}
|
||||
if telegramUser != "" {
|
||||
data = append(data, NotificationPref{NotifAgentTelegram, id, telegramUser, true})
|
||||
}
|
||||
var code int
|
||||
result, code, err = ombi.send("POST", url, data, true, map[string]string{"UserName": user["userName"].(string)})
|
||||
err = co.GenericErr(code, err)
|
||||
|
||||
Reference in New Issue
Block a user