aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-01-17 08:33:25 -0600
committerNathan Ringo <nathan@remexre.com>2024-01-17 08:33:25 -0600
commit59accae1e5b6848592b0beaa6f0e6c481288d357 (patch)
treeac286b396d0d4df7efbdeba1c080b2a67301c491
parent916af135916f72b6d09f80d32ae1081e25aa5bdb (diff)
Don't try to re-add a role the user already has.
-rw-r--r--.gitignore1
-rw-r--r--src/handlers/x500_mapper.rs10
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>(())