Fix canonical alias event check
The old version was checking all aliases instead of only the newly added ones that prevented modifying the event if one of current aliases became invalid
This commit is contained in:
20
Cargo.lock
generated
20
Cargo.lock
generated
@@ -3754,7 +3754,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma"
|
||||
version = "0.13.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"js_int",
|
||||
@@ -3773,7 +3773,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-appservice-api"
|
||||
version = "0.13.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
@@ -3785,7 +3785,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
version = "0.21.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"assign",
|
||||
@@ -3810,7 +3810,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-common"
|
||||
version = "0.16.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"base64",
|
||||
@@ -3844,7 +3844,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-events"
|
||||
version = "0.31.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"indexmap",
|
||||
@@ -3871,7 +3871,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-federation-api"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"headers",
|
||||
@@ -3894,7 +3894,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identifiers-validation"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"thiserror 2.0.18",
|
||||
@@ -3903,7 +3903,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-macros"
|
||||
version = "0.16.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"proc-macro-crate",
|
||||
@@ -3918,7 +3918,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-push-gateway-api"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
@@ -3930,7 +3930,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-signatures"
|
||||
version = "0.18.0"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=2f53677f4d621cb4560119c5938888c9ce983e56#2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
source = "git+https://github.com/matrix-construct/ruma?rev=3cb939f5c8a67197433cbb3dc7e256f0ddaee978#3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"ed25519-dalek",
|
||||
|
||||
@@ -320,7 +320,7 @@ default-features = false
|
||||
|
||||
[workspace.dependencies.ruma]
|
||||
git = "https://github.com/matrix-construct/ruma"
|
||||
rev = "2f53677f4d621cb4560119c5938888c9ce983e56"
|
||||
rev = "3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||
features = [
|
||||
"__compat",
|
||||
"appservice-api-c",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use axum::extract::State;
|
||||
use futures::{FutureExt, TryFutureExt, TryStreamExt};
|
||||
use ruma::{
|
||||
OwnedEventId, RoomId, UserId,
|
||||
OwnedEventId, OwnedRoomAliasId, RoomId, UserId,
|
||||
api::client::state::{get_state_event_for_key, get_state_events, send_state_event},
|
||||
events::{
|
||||
AnyStateEventContent, StateEventType,
|
||||
@@ -320,16 +320,28 @@ async fn allowed_to_send_state_event(
|
||||
| StateEventType::RoomCanonicalAlias => {
|
||||
match json.deserialize_as_unchecked::<RoomCanonicalAliasEventContent>() {
|
||||
| Ok(canonical_alias_content) => {
|
||||
let mut aliases = canonical_alias_content.alt_aliases.clone();
|
||||
let current_event = services
|
||||
.state_accessor
|
||||
.room_state_get_content::<RoomCanonicalAliasEventContent>(
|
||||
room_id,
|
||||
&StateEventType::RoomCanonicalAlias,
|
||||
"",
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
|
||||
if let Some(alias) = canonical_alias_content.alias {
|
||||
aliases.push(alias);
|
||||
}
|
||||
let current_aliases: Vec<OwnedRoomAliasId> = current_event
|
||||
.map(|content| content.aliases().cloned().collect())
|
||||
.unwrap_or_default();
|
||||
|
||||
let aliases = canonical_alias_content
|
||||
.aliases()
|
||||
.filter(|alias| !current_aliases.contains(alias));
|
||||
|
||||
for alias in aliases {
|
||||
let (alias_room_id, _servers) = services
|
||||
.alias
|
||||
.resolve_alias(&alias)
|
||||
.resolve_alias(alias)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
err!(Request(BadAlias("Failed resolving alias \"{alias}\": {e}")))
|
||||
|
||||
Reference in New Issue
Block a user