Commit 87601f4b82
Unsigned
Layout: unified · split
src/commands/redact.rs +1 −12
| @@ -91,19 +91,8 @@ impl RedactCommand { | ||
| 91 | 91 | reason: Option<String>, |
| 92 | 92 | ) { |
| 93 | 93 | if let Some(room) = self.servers.find_room(buffer) { |
| 94 | let room = room.room().clone(); | |
| 95 | ||
| 96 | 94 | Weechat::spawn(async move { |
| 97 | if let Err(error) = | |
| 98 | room.redact(&event_id, reason.as_deref(), None).await | |
| 99 | { | |
| 100 | Weechat::print(&format!( | |
| 101 | "{}Failed to redact {}: {}", | |
| 102 | Weechat::prefix(Prefix::Error), | |
| 103 | event_id, | |
| 104 | error | |
| 105 | )); | |
| 106 | } | |
| 95 | room.send_redaction(event_id, reason).await | |
| 107 | 96 | }) |
| 108 | 97 | .detach(); |
| 109 | 98 | } else { |
src/room/mod.rs +27
| @@ -1026,6 +1026,33 @@ impl MatrixRoom { | ||
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | pub async fn send_redaction( | |
| 1030 | &self, | |
| 1031 | event_id: OwnedEventId, | |
| 1032 | reason: Option<String>, | |
| 1033 | ) { | |
| 1034 | let Some(connection) = self.connection.borrow().clone() else { | |
| 1035 | self.print_error("Not connected. Please connect first."); | |
| 1036 | return; | |
| 1037 | }; | |
| 1038 | ||
| 1039 | let room = self.room().clone(); | |
| 1040 | let error_event_id = event_id.clone(); | |
| 1041 | ||
| 1042 | match connection | |
| 1043 | .spawn(async move { | |
| 1044 | room.redact(&event_id, reason.as_deref(), None).await | |
| 1045 | }) | |
| 1046 | .await | |
| 1047 | { | |
| 1048 | Ok(_) => (), | |
| 1049 | Err(error) => self.print_error(&format!( | |
| 1050 | "Failed to redact {}: {}", | |
| 1051 | error_event_id, error | |
| 1052 | )), | |
| 1053 | } | |
| 1054 | } | |
| 1055 | ||
| 1029 | 1056 | pub async fn send_attachment(&self, path: PathBuf) { |
| 1030 | 1057 | let Some(filename) = path |
| 1031 | 1058 | .file_name() |