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]]
|
[[package]]
|
||||||
name = "ruma"
|
name = "ruma"
|
||||||
version = "0.13.0"
|
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 = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"js_int",
|
"js_int",
|
||||||
@@ -3773,7 +3773,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-appservice-api"
|
name = "ruma-appservice-api"
|
||||||
version = "0.13.0"
|
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 = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -3785,7 +3785,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-client-api"
|
name = "ruma-client-api"
|
||||||
version = "0.21.0"
|
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 = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"assign",
|
"assign",
|
||||||
@@ -3810,7 +3810,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-common"
|
name = "ruma-common"
|
||||||
version = "0.16.0"
|
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 = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"base64",
|
"base64",
|
||||||
@@ -3844,7 +3844,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events"
|
name = "ruma-events"
|
||||||
version = "0.31.0"
|
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 = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
@@ -3871,7 +3871,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-federation-api"
|
name = "ruma-federation-api"
|
||||||
version = "0.12.0"
|
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 = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"headers",
|
"headers",
|
||||||
@@ -3894,7 +3894,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-validation"
|
name = "ruma-identifiers-validation"
|
||||||
version = "0.11.0"
|
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 = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
@@ -3903,7 +3903,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-macros"
|
name = "ruma-macros"
|
||||||
version = "0.16.0"
|
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 = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
@@ -3918,7 +3918,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-push-gateway-api"
|
name = "ruma-push-gateway-api"
|
||||||
version = "0.12.0"
|
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 = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
@@ -3930,7 +3930,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-signatures"
|
name = "ruma-signatures"
|
||||||
version = "0.18.0"
|
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 = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ default-features = false
|
|||||||
|
|
||||||
[workspace.dependencies.ruma]
|
[workspace.dependencies.ruma]
|
||||||
git = "https://github.com/matrix-construct/ruma"
|
git = "https://github.com/matrix-construct/ruma"
|
||||||
rev = "2f53677f4d621cb4560119c5938888c9ce983e56"
|
rev = "3cb939f5c8a67197433cbb3dc7e256f0ddaee978"
|
||||||
features = [
|
features = [
|
||||||
"__compat",
|
"__compat",
|
||||||
"appservice-api-c",
|
"appservice-api-c",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use futures::{FutureExt, TryFutureExt, TryStreamExt};
|
use futures::{FutureExt, TryFutureExt, TryStreamExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedEventId, RoomId, UserId,
|
OwnedEventId, OwnedRoomAliasId, RoomId, UserId,
|
||||||
api::client::state::{get_state_event_for_key, get_state_events, send_state_event},
|
api::client::state::{get_state_event_for_key, get_state_events, send_state_event},
|
||||||
events::{
|
events::{
|
||||||
AnyStateEventContent, StateEventType,
|
AnyStateEventContent, StateEventType,
|
||||||
@@ -320,16 +320,28 @@ async fn allowed_to_send_state_event(
|
|||||||
| StateEventType::RoomCanonicalAlias => {
|
| StateEventType::RoomCanonicalAlias => {
|
||||||
match json.deserialize_as_unchecked::<RoomCanonicalAliasEventContent>() {
|
match json.deserialize_as_unchecked::<RoomCanonicalAliasEventContent>() {
|
||||||
| Ok(canonical_alias_content) => {
|
| 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 {
|
let current_aliases: Vec<OwnedRoomAliasId> = current_event
|
||||||
aliases.push(alias);
|
.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 {
|
for alias in aliases {
|
||||||
let (alias_room_id, _servers) = services
|
let (alias_room_id, _servers) = services
|
||||||
.alias
|
.alias
|
||||||
.resolve_alias(&alias)
|
.resolve_alias(alias)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
err!(Request(BadAlias("Failed resolving alias \"{alias}\": {e}")))
|
err!(Request(BadAlias("Failed resolving alias \"{alias}\": {e}")))
|
||||||
|
|||||||
Reference in New Issue
Block a user