mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-03-29 10:50:15 +00:00
fix(alias): preserve room alias enumeration on delete
This commit is contained in:
1
changelog.d/+alias-enumeration-delete.bugfix.md
Normal file
1
changelog.d/+alias-enumeration-delete.bugfix.md
Normal file
@@ -0,0 +1 @@
|
||||
Fixed room alias deletion so removing one local alias no longer removes other aliases from room alias listings.
|
||||
@@ -104,17 +104,13 @@ pub async fn remove_alias(&self, alias: &RoomAliasId, user_id: &UserId) -> Resul
|
||||
return Err!(Request(Forbidden("User is not permitted to remove this alias.")));
|
||||
}
|
||||
|
||||
let alias_full = alias.as_bytes().to_vec();
|
||||
let alias = alias.alias();
|
||||
let Ok(room_id) = self.db.alias_roomid.get(&alias).await else {
|
||||
return Err!(Request(NotFound("Alias does not exist or is invalid.")));
|
||||
};
|
||||
|
||||
let prefix = (&room_id, Interfix);
|
||||
self.db
|
||||
.aliasid_alias
|
||||
.keys_prefix_raw(&prefix)
|
||||
.ignore_err()
|
||||
.ready_for_each(|key| self.db.aliasid_alias.remove(key))
|
||||
self.remove_aliasid_alias_entries(&room_id, &alias_full)
|
||||
.await;
|
||||
|
||||
self.db.alias_roomid.remove(alias.as_bytes());
|
||||
@@ -274,6 +270,22 @@ async fn who_created_alias(&self, alias: &RoomAliasId) -> Result<OwnedUserId> {
|
||||
self.db.alias_userid.get(alias.alias()).await.deserialized()
|
||||
}
|
||||
|
||||
async fn remove_aliasid_alias_entries(&self, room_id: &[u8], alias_full: &[u8]) {
|
||||
let prefix = (room_id, Interfix);
|
||||
let keys: Vec<Vec<u8>> = self
|
||||
.db
|
||||
.aliasid_alias
|
||||
.stream_prefix_raw(&prefix)
|
||||
.ignore_err()
|
||||
.ready_filter_map(|(key, value)| (value == alias_full).then_some(key.to_vec()))
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
for key in keys {
|
||||
self.db.aliasid_alias.remove(&key);
|
||||
}
|
||||
}
|
||||
|
||||
async fn resolve_appservice_alias(
|
||||
&self,
|
||||
room_alias: &RoomAliasId,
|
||||
|
||||
Reference in New Issue
Block a user