|
|
@ -49,7 +49,7 @@ use ruma::{
|
|
|
|
to_device::DeviceIdOrAllDevices,
|
|
|
|
to_device::DeviceIdOrAllDevices,
|
|
|
|
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch,
|
|
|
|
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch,
|
|
|
|
OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, RoomId,
|
|
|
|
OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, RoomId,
|
|
|
|
ServerName,
|
|
|
|
RoomVersionId, ServerName,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
|
|
|
|
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
|
|
|
|
use std::{
|
|
|
|
use std::{
|
|
|
@ -1758,6 +1758,30 @@ async fn create_join_event(
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let event_content: RoomMemberEventContent = serde_json::from_value(
|
|
|
|
|
|
|
|
value
|
|
|
|
|
|
|
|
.get("content")
|
|
|
|
|
|
|
|
.ok_or_else(|| Error::BadRequest(ErrorKind::BadJson, "Missing event content"))?
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
.into(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Invalid event content"))?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if event_content
|
|
|
|
|
|
|
|
.join_authorized_via_users_server
|
|
|
|
|
|
|
|
.map(|user| user.server_name() == services().globals.server_name())
|
|
|
|
|
|
|
|
.unwrap_or_default()
|
|
|
|
|
|
|
|
&& !matches!(
|
|
|
|
|
|
|
|
room_version_id,
|
|
|
|
|
|
|
|
RoomVersionId::V1
|
|
|
|
|
|
|
|
| RoomVersionId::V2
|
|
|
|
|
|
|
|
| RoomVersionId::V3
|
|
|
|
|
|
|
|
| RoomVersionId::V4
|
|
|
|
|
|
|
|
| RoomVersionId::V5
|
|
|
|
|
|
|
|
| RoomVersionId::V6
|
|
|
|
|
|
|
|
| RoomVersionId::V7
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
ruma::signatures::hash_and_sign_event(
|
|
|
|
ruma::signatures::hash_and_sign_event(
|
|
|
|
services().globals.server_name().as_str(),
|
|
|
|
services().globals.server_name().as_str(),
|
|
|
|
services().globals.keypair(),
|
|
|
|
services().globals.keypair(),
|
|
|
@ -1765,6 +1789,7 @@ async fn create_join_event(
|
|
|
|
&room_version_id,
|
|
|
|
&room_version_id,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "Failed to sign event."))?;
|
|
|
|
.map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "Failed to sign event."))?;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let origin: OwnedServerName = serde_json::from_value(
|
|
|
|
let origin: OwnedServerName = serde_json::from_value(
|
|
|
|
serde_json::to_value(value.get("origin").ok_or(Error::BadRequest(
|
|
|
|
serde_json::to_value(value.get("origin").ok_or(Error::BadRequest(
|
|
|
|