src: matrix: Slightly better error handling when pinning messages

This commit is contained in:
mirsal committed 2026-09-17 13:05:21 +00:00
1 parent db0eb7db5e
commit 624d90f3c9
1 file changed
+10 -4
+10 -4
View File
@@ -55,6 +55,7 @@ async fn on_stripped_state_member(
client: Client,
room: Room,
) {
//XXX: Panic if authentication has failed
if room_member.state_key != client.user_id().unwrap() {
return;
}
@@ -97,11 +98,16 @@ async fn send_to_room(
let mut new_pinned_eids = Vec::with_capacity(old_pinned_eids.len());
for eid in old_pinned_eids.drain(..) {
if let Ok(e) = room.event(eid.as_ref(), None).await {
let client = room.client();
match room.event(eid.as_ref(), None).await {
Ok(ev) => {
let client = room.client();
if client.user_id() != e.sender().as_deref() {
new_pinned_eids.push(eid);
if client.user_id() != ev.sender().as_deref() {
new_pinned_eids.push(eid);
}
},
Err(err) => {
error!("Failed to retrieve pinned event {eid:?}: {err:?}");
}
}
}