Skip to content

Commit

Permalink
fixup! fixup! fix(pinned_events): get pinned event ids from the HS if…
Browse files Browse the repository at this point in the history
… the sync doesn't contain it
  • Loading branch information
jmartinesp committed Nov 4, 2024
1 parent f1914c7 commit 7e82a24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 4 additions & 4 deletions crates/matrix-sdk-ui/tests/integration/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ impl PinningTestSetup<'_> {

// This is necessary to get an empty list of pinned events when there are no
// pinned events state event in the required state
setup.mock_get_empty_state_response().await;
setup.mock_get_empty_pinned_events_state_response().await;

setup
}
Expand All @@ -862,11 +862,11 @@ impl PinningTestSetup<'_> {
.await;
}

async fn mock_get_empty_state_response(&self) {
async fn mock_get_empty_pinned_events_state_response(&self) {
Mock::given(method("GET"))
.and(path_regex(r"^/_matrix/client/r0/rooms/.*/state"))
.and(path_regex(r"^/_matrix/client/r0/rooms/.*/state/m.room.pinned_events/.*"))
.and(header("authorization", "Bearer 1234"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!([])))
.respond_with(ResponseTemplate::new(404).set_body_json(json!({})))
.mount(&self.server)
.await;
}
Expand Down
13 changes: 11 additions & 2 deletions crates/matrix-sdk/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use futures_util::{
future::{try_join, try_join_all},
stream::FuturesUnordered,
};
use http::StatusCode;
#[cfg(all(feature = "e2e-encryption", not(target_arch = "wasm32")))]
pub use identity_status_changes::IdentityStatusChanges;
#[cfg(feature = "e2e-encryption")]
Expand Down Expand Up @@ -3145,9 +3146,17 @@ impl Room {
),
None,
)
.await?;
.await;

Ok(Some(response.content.deserialize_as::<RoomPinnedEventsEventContent>()?.pinned))
match response {
Ok(response) => {
Ok(Some(response.content.deserialize_as::<RoomPinnedEventsEventContent>()?.pinned))
}
Err(http_error) => match http_error.as_client_api_error() {
Some(error) if error.status_code == StatusCode::NOT_FOUND => Ok(None),
_ => Err(http_error.into()),
},
}
}
}

Expand Down

0 comments on commit 7e82a24

Please sign in to comment.