chore: Remove empty scopemaps (#3170)

This commit is contained in:
CEbbinghaus 2025-02-09 01:19:52 +00:00 committed by GitHub
parent 7a9bb9eac2
commit f68906bf1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -200,6 +200,7 @@ pub(crate) async fn oauth2_id_scopemap_post(
Json(scopes): Json<Vec<String>>, Json(scopes): Json<Vec<String>>,
) -> Result<Json<()>, WebError> { ) -> Result<Json<()>, WebError> {
let filter = oauth2_id(&rs_name); let filter = oauth2_id(&rs_name);
state state
.qe_w_ref .qe_w_ref
.handle_oauth2_scopemap_update(client_auth_info, group, scopes, filter, kopid.eventid) .handle_oauth2_scopemap_update(client_auth_info, group, scopes, filter, kopid.eventid)

View file

@ -279,6 +279,7 @@ impl ValueSetT for ValueSetOauthScopeMap {
match value { match value {
Value::OauthScopeMap(u, m) => { Value::OauthScopeMap(u, m) => {
match self.map.entry(u) { match self.map.entry(u) {
// We are going to assume that a vacant entry will not be set to empty.
BTreeEntry::Vacant(e) => { BTreeEntry::Vacant(e) => {
e.insert(m); e.insert(m);
Ok(true) Ok(true)
@ -289,7 +290,12 @@ impl ValueSetT for ValueSetOauthScopeMap {
// associated map state. So by always replacing on a present, we are true to // associated map state. So by always replacing on a present, we are true to
// the intent of the api. // the intent of the api.
BTreeEntry::Occupied(mut e) => { BTreeEntry::Occupied(mut e) => {
e.insert(m); if m.is_empty() {
e.remove();
} else {
e.insert(m);
}
Ok(true) Ok(true)
} }
} }