hive-matrix-mcp: add send_redact tool to delete matrix events
This commit is contained in:
parent
79af902d47
commit
1c0f7a72f7
4 changed files with 106 additions and 3 deletions
|
|
@ -6,8 +6,8 @@
|
|||
//!
|
||||
//! Tool surface mirrors damocles-daemon's v0 set per the operator's call:
|
||||
//! `send_message`, `send_dm`, `send_reaction`, `send_reply`, `mark_read`,
|
||||
//! `list_rooms`, `list_room_members`, `read_room`. Plus a `ping` for the
|
||||
//! MCP bridge's liveness probe.
|
||||
//! `send_redact`, `list_rooms`, `list_room_members`, `read_room`. Plus a
|
||||
//! `ping` for the MCP bridge's liveness probe.
|
||||
|
||||
use matrix_sdk::{
|
||||
Client,
|
||||
|
|
@ -407,6 +407,32 @@ pub async fn mark_read(client: &Client, room_ref: &str, event_id: &str) -> Daemo
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn send_redact(
|
||||
client: &Client,
|
||||
room_ref: &str,
|
||||
event_id: &str,
|
||||
reason: Option<&str>,
|
||||
) -> DaemonResponse {
|
||||
let room = match resolve_room(client, room_ref).await {
|
||||
Ok(r) => r,
|
||||
Err(e) => return e,
|
||||
};
|
||||
let eid: OwnedEventId = match event_id.parse() {
|
||||
Ok(e) => e,
|
||||
Err(e) => return DaemonResponse::error(format!("invalid event_id {event_id}: {e}")),
|
||||
};
|
||||
// Redaction is irreversible: the homeserver drops the event content and
|
||||
// keeps only the shell + reason. A fresh txn id (None) is fine — this is
|
||||
// a one-shot operator/agent action, not a retried send.
|
||||
match room.redact(&eid, reason, None).await {
|
||||
Ok(resp) => DaemonResponse::ok(&serde_json::json!({
|
||||
"event_id": resp.event_id.to_string(),
|
||||
"target": eid.to_string(),
|
||||
})),
|
||||
Err(e) => DaemonResponse::error(format!("redact {eid}: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn list_rooms(client: &Client) -> DaemonResponse {
|
||||
let mut rooms = Vec::new();
|
||||
for room in client.joined_rooms() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue