housekeeping/discord: respect remove role on disable setting

only remove it if it's set to true.
This commit is contained in:
Harvey Tindall
2025-11-30 21:59:46 +00:00
parent b525b03ef8
commit 50455b828d

View File

@@ -31,6 +31,7 @@ func (app *appContext) clearEmails() {
func (app *appContext) clearDiscord() { func (app *appContext) clearDiscord() {
app.debug.Println(lm.HousekeepingDiscord) app.debug.Println(lm.HousekeepingDiscord)
discordUsers := app.storage.GetDiscord() discordUsers := app.storage.GetDiscord()
removeRoleOnDisable := app.config.Section("discord").Key("disable_enable_role").MustBool(false)
for _, discordUser := range discordUsers { for _, discordUser := range discordUsers {
user, err := app.jf.UserByID(discordUser.JellyfinID, false) user, err := app.jf.UserByID(discordUser.JellyfinID, false)
// Make sure the user doesn't exist, and no other error has occured // Make sure the user doesn't exist, and no other error has occured
@@ -40,7 +41,7 @@ func (app *appContext) clearDiscord() {
app.discord.RemoveRole(discordUser.MethodID().(string)) app.discord.RemoveRole(discordUser.MethodID().(string))
app.storage.DeleteDiscordKey(discordUser.JellyfinID) app.storage.DeleteDiscordKey(discordUser.JellyfinID)
default: default:
if user.Policy.IsDisabled { if removeRoleOnDisable && user.Policy.IsDisabled {
app.discord.RemoveRole(discordUser.MethodID().(string)) app.discord.RemoveRole(discordUser.MethodID().(string))
} }
continue continue