mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
fix service/rooms/spaces events
This commit is contained in:
parent
b4d81bb067
commit
96e6ac9563
1 changed files with 52 additions and 28 deletions
|
|
@ -179,11 +179,10 @@ impl Service {
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
serde_json::from_str(s.content.get())
|
serde_json::from_str(s.content.get())
|
||||||
.map(|c: RoomJoinRulesEventContent| c.join_rule)
|
.map(|c: RoomJoinRulesEventContent| c.join_rule)
|
||||||
.map_err(|e| {
|
.map_err(|error| {
|
||||||
error!(
|
error!(
|
||||||
"Invalid room join rule event in \
|
%error,
|
||||||
database: {}",
|
"Invalid room join rule event"
|
||||||
e
|
|
||||||
);
|
);
|
||||||
Error::BadDatabase(
|
Error::BadDatabase(
|
||||||
"Invalid room join rule event in \
|
"Invalid room join rule event in \
|
||||||
|
|
@ -218,7 +217,7 @@ impl Service {
|
||||||
// Early return so the client can see some data already
|
// Early return so the client can see some data already
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
debug!("Asking {server} for /hierarchy");
|
debug!(%server, "Asking other server for /hierarchy");
|
||||||
if let Ok(response) = services()
|
if let Ok(response) = services()
|
||||||
.sending
|
.sending
|
||||||
.send_federation_request(
|
.send_federation_request(
|
||||||
|
|
@ -231,8 +230,9 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
warn!(
|
warn!(
|
||||||
"Got response from {server} for \
|
%server,
|
||||||
/hierarchy\n{response:?}"
|
?response,
|
||||||
|
"Got response from other server for /hierarchy",
|
||||||
);
|
);
|
||||||
let chunk = SpaceHierarchyRoomsChunk {
|
let chunk = SpaceHierarchyRoomsChunk {
|
||||||
canonical_alias: response.room.canonical_alias,
|
canonical_alias: response.room.canonical_alias,
|
||||||
|
|
@ -327,7 +327,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(skip(self, sender_user, children))]
|
#[tracing::instrument(skip(self, children))]
|
||||||
fn get_room_chunk(
|
fn get_room_chunk(
|
||||||
&self,
|
&self,
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
|
|
@ -346,8 +346,13 @@ impl Service {
|
||||||
.map_or(Ok(None), |s| {
|
.map_or(Ok(None), |s| {
|
||||||
serde_json::from_str(s.content.get())
|
serde_json::from_str(s.content.get())
|
||||||
.map(|c: RoomCanonicalAliasEventContent| c.alias)
|
.map(|c: RoomCanonicalAliasEventContent| c.alias)
|
||||||
.map_err(|_| {
|
.map_err(|error| {
|
||||||
Error::bad_database(
|
error!(
|
||||||
|
%error,
|
||||||
|
event_id = %s.event_id,
|
||||||
|
"Invalid room canonical alias event"
|
||||||
|
);
|
||||||
|
Error::BadDatabase(
|
||||||
"Invalid canonical alias event in database.",
|
"Invalid canonical alias event in database.",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -358,7 +363,7 @@ impl Service {
|
||||||
.state_cache
|
.state_cache
|
||||||
.room_joined_count(room_id)?
|
.room_joined_count(room_id)?
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
warn!("Room {} has no member count", room_id);
|
warn!("Room has no member count");
|
||||||
0
|
0
|
||||||
})
|
})
|
||||||
.try_into()
|
.try_into()
|
||||||
|
|
@ -371,13 +376,13 @@ impl Service {
|
||||||
.map_or(Ok(None), |s| {
|
.map_or(Ok(None), |s| {
|
||||||
serde_json::from_str(s.content.get())
|
serde_json::from_str(s.content.get())
|
||||||
.map(|c: RoomTopicEventContent| Some(c.topic))
|
.map(|c: RoomTopicEventContent| Some(c.topic))
|
||||||
.map_err(|_| {
|
.map_err(|error| {
|
||||||
error!(
|
error!(
|
||||||
"Invalid room topic event in database for \
|
%error,
|
||||||
room {}",
|
event_id = %s.event_id,
|
||||||
room_id
|
"Invalid room topic event"
|
||||||
);
|
);
|
||||||
Error::bad_database(
|
Error::BadDatabase(
|
||||||
"Invalid room topic event in database.",
|
"Invalid room topic event in database.",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -396,8 +401,13 @@ impl Service {
|
||||||
c.history_visibility
|
c.history_visibility
|
||||||
== HistoryVisibility::WorldReadable
|
== HistoryVisibility::WorldReadable
|
||||||
})
|
})
|
||||||
.map_err(|_| {
|
.map_err(|error| {
|
||||||
Error::bad_database(
|
error!(
|
||||||
|
%error,
|
||||||
|
event_id = %s.event_id,
|
||||||
|
"Invalid room history visibility event"
|
||||||
|
);
|
||||||
|
Error::BadDatabase(
|
||||||
"Invalid room history visibility event in \
|
"Invalid room history visibility event in \
|
||||||
database.",
|
database.",
|
||||||
)
|
)
|
||||||
|
|
@ -412,8 +422,13 @@ impl Service {
|
||||||
.map(|c: RoomGuestAccessEventContent| {
|
.map(|c: RoomGuestAccessEventContent| {
|
||||||
c.guest_access == GuestAccess::CanJoin
|
c.guest_access == GuestAccess::CanJoin
|
||||||
})
|
})
|
||||||
.map_err(|_| {
|
.map_err(|error| {
|
||||||
Error::bad_database(
|
error!(
|
||||||
|
%error,
|
||||||
|
event_id = %s.event_id,
|
||||||
|
"Invalid room guest access event"
|
||||||
|
);
|
||||||
|
Error::BadDatabase(
|
||||||
"Invalid room guest access event in database.",
|
"Invalid room guest access event in database.",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -425,7 +440,12 @@ impl Service {
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
serde_json::from_str(s.content.get())
|
serde_json::from_str(s.content.get())
|
||||||
.map(|c: RoomAvatarEventContent| c.url)
|
.map(|c: RoomAvatarEventContent| c.url)
|
||||||
.map_err(|_| {
|
.map_err(|error| {
|
||||||
|
error!(
|
||||||
|
%error,
|
||||||
|
event_id = %s.event_id,
|
||||||
|
"Invalid room avatar event"
|
||||||
|
);
|
||||||
Error::bad_database(
|
Error::bad_database(
|
||||||
"Invalid room avatar event in database.",
|
"Invalid room avatar event in database.",
|
||||||
)
|
)
|
||||||
|
|
@ -445,11 +465,11 @@ impl Service {
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
serde_json::from_str(s.content.get())
|
serde_json::from_str(s.content.get())
|
||||||
.map(|c: RoomJoinRulesEventContent| c.join_rule)
|
.map(|c: RoomJoinRulesEventContent| c.join_rule)
|
||||||
.map_err(|e| {
|
.map_err(|error| {
|
||||||
error!(
|
error!(
|
||||||
"Invalid room join rule event in \
|
%error,
|
||||||
database: {}",
|
event_id = %s.event_id,
|
||||||
e
|
"Invalid room join rule event",
|
||||||
);
|
);
|
||||||
Error::BadDatabase(
|
Error::BadDatabase(
|
||||||
"Invalid room join rule event in database.",
|
"Invalid room join rule event in database.",
|
||||||
|
|
@ -460,7 +480,7 @@ impl Service {
|
||||||
.unwrap_or(JoinRule::Invite);
|
.unwrap_or(JoinRule::Invite);
|
||||||
|
|
||||||
if !self.handle_join_rule(&join_rule, sender_user, room_id)? {
|
if !self.handle_join_rule(&join_rule, sender_user, room_id)? {
|
||||||
debug!("User is not allowed to see room {room_id}");
|
debug!("User is not allowed to see room");
|
||||||
// This error will be caught later
|
// This error will be caught later
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::forbidden(),
|
ErrorKind::forbidden(),
|
||||||
|
|
@ -478,8 +498,12 @@ impl Service {
|
||||||
serde_json::from_str::<RoomCreateEventContent>(
|
serde_json::from_str::<RoomCreateEventContent>(
|
||||||
s.content.get(),
|
s.content.get(),
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|error| {
|
||||||
error!("Invalid room create event in database: {}", e);
|
error!(
|
||||||
|
%error,
|
||||||
|
event_id = %s.event_id,
|
||||||
|
"Invalid room create event",
|
||||||
|
);
|
||||||
Error::BadDatabase(
|
Error::BadDatabase(
|
||||||
"Invalid room create event in database.",
|
"Invalid room create event in database.",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue