Handle GrizzlyFlix signup mail and Seerr sync failures
This commit is contained in:
+12
-2
@@ -14,6 +14,10 @@ type JellyseerrInitialSyncStatus struct {
|
||||
Done bool
|
||||
}
|
||||
|
||||
func isJellyseerrCSRFFailure(err error) bool {
|
||||
return err != nil && strings.Contains(strings.ToLower(err.Error()), "invalid csrf token")
|
||||
}
|
||||
|
||||
// Ensure the Jellyseerr cache is up to date before calling.
|
||||
func (app *appContext) SynchronizeJellyseerrUser(jfID string) {
|
||||
user, imported, err := app.js.GetOrImportUser(jfID, true)
|
||||
@@ -35,7 +39,9 @@ func (app *appContext) SynchronizeJellyseerrUser(jfID string) {
|
||||
if ok && email.Addr != "" && user.Email != email.Addr {
|
||||
err = app.js.ModifyMainUserSettings(jfID, jellyseerr.MainUserSettings{Email: email.Addr})
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "INVALID_EMAIL") {
|
||||
if isJellyseerrCSRFFailure(err) && app.config.Section("jellyseerr").Key("ignore_csrf_email_update_errors").MustBool(true) {
|
||||
app.debug.Printf("Skipping Jellyseerr email update for user \"%s\": Jellyseerr rejected the API-key write with CSRF protection", jfID)
|
||||
} else if strings.Contains(err.Error(), "INVALID_EMAIL") {
|
||||
app.err.Printf(lm.FailedSetEmailAddress, lm.Jellyseerr, jfID, err.Error()+"\""+email.Addr+"\"")
|
||||
} else {
|
||||
app.err.Printf(lm.FailedSetEmailAddress, lm.Jellyseerr, jfID, err)
|
||||
@@ -63,7 +69,11 @@ func (app *appContext) SynchronizeJellyseerrUser(jfID string) {
|
||||
if len(contactMethods) != 0 {
|
||||
err := app.js.ModifyNotifications(jfID, contactMethods)
|
||||
if err != nil {
|
||||
app.err.Printf(lm.FailedSyncContactMethods, lm.Jellyseerr, err)
|
||||
if isJellyseerrCSRFFailure(err) && app.config.Section("jellyseerr").Key("ignore_csrf_email_update_errors").MustBool(true) {
|
||||
app.debug.Printf("Skipping Jellyseerr notification update for user \"%s\": Jellyseerr rejected the API-key write with CSRF protection", jfID)
|
||||
} else {
|
||||
app.err.Printf(lm.FailedSyncContactMethods, lm.Jellyseerr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user