mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-19 21:29:52 -07:00
Support redacting messages (#5)
This commit is contained in:
parent
d13d4b9f7f
commit
56ec90523c
6 changed files with 132 additions and 8 deletions
|
@ -35,6 +35,7 @@ use matrix_sdk::{
|
|||
room::{
|
||||
message::{MessageType, RoomMessageEventContent},
|
||||
name::RoomNameEventContent,
|
||||
redaction::{OriginalSyncRoomRedactionEvent, SyncRoomRedactionEvent},
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
typing::SyncTypingEvent,
|
||||
|
@ -46,6 +47,7 @@ use matrix_sdk::{
|
|||
OwnedRoomId,
|
||||
OwnedRoomOrAliasId,
|
||||
OwnedUserId,
|
||||
RoomVersionId,
|
||||
},
|
||||
Client,
|
||||
DisplayName,
|
||||
|
@ -547,6 +549,34 @@ impl ClientWorker {
|
|||
},
|
||||
);
|
||||
|
||||
let _ = self.client.add_event_handler(
|
||||
|ev: OriginalSyncRoomRedactionEvent,
|
||||
room: MatrixRoom,
|
||||
store: Ctx<AsyncProgramStore>| {
|
||||
async move {
|
||||
let room_id = room.room_id();
|
||||
let room_info = room.clone_info();
|
||||
let room_version = room_info.room_version().unwrap_or(&RoomVersionId::V1);
|
||||
|
||||
let mut locked = store.lock().await;
|
||||
let info = locked.application.get_room_info(room_id.to_owned());
|
||||
|
||||
// XXX: need to store a mapping of EventId -> MessageKey somewhere
|
||||
// to avoid having to iterate over the messages here.
|
||||
for ((_, id), msg) in info.messages.iter_mut().rev() {
|
||||
if id != &ev.redacts {
|
||||
continue;
|
||||
}
|
||||
|
||||
let ev = SyncRoomRedactionEvent::Original(ev);
|
||||
msg.event.redact(ev, room_version);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let _ = self.client.add_event_handler(
|
||||
|ev: OriginalSyncKeyVerificationStartEvent,
|
||||
client: Client,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue