From 59accae1e5b6848592b0beaa6f0e6c481288d357 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Wed, 17 Jan 2024 08:33:25 -0600 Subject: Don't try to re-add a role the user already has. --- .gitignore | 1 + src/handlers/x500_mapper.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b9367b3..4c39c23 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ target/ lambo.db lambo.db-shm lambo.db-wal +lambo.log lambo.toml diff --git a/src/handlers/x500_mapper.rs b/src/handlers/x500_mapper.rs index 36ce386..1ec35f2 100644 --- a/src/handlers/x500_mapper.rs +++ b/src/handlers/x500_mapper.rs @@ -113,10 +113,12 @@ impl X500Mapper { if let Some(role) = self.config.students_role { log::info!("adding the role {} to {}", role, member.display_name()); - member - .add_role(&ctx.http, role) - .await - .context("failed to add student role")? + if !member.roles.contains(&role) { + member + .add_role(&ctx.http, role) + .await + .context("failed to add student role")? + } } Ok::<_, anyhow::Error>(()) -- cgit v1.2.3