fix(core): align CLI channel send call with SendMessage

This commit is contained in:
Chummy 2026-02-18 00:08:36 +08:00
parent 7e3f5ff497
commit 318e0fa9a7

View file

@ -49,9 +49,7 @@ impl MattermostChannel {
.await .await
.ok()?; .ok()?;
resp.get("id") resp.get("id").and_then(|u| u.as_str()).map(String::from)
.and_then(|u| u.as_str())
.map(String::from)
} }
} }
@ -76,10 +74,10 @@ impl Channel for MattermostChannel {
}); });
if let Some(root) = root_id { if let Some(root) = root_id {
body_map body_map.as_object_mut().unwrap().insert(
.as_object_mut() "root_id".to_string(),
.unwrap() serde_json::Value::String(root.to_string()),
.insert("root_id".to_string(), serde_json::Value::String(root.to_string())); );
} }
let resp = self let resp = self
@ -152,7 +150,8 @@ impl Channel for MattermostChannel {
post_list.sort_by_key(|p| p.get("create_at").and_then(|c| c.as_i64()).unwrap_or(0)); post_list.sort_by_key(|p| p.get("create_at").and_then(|c| c.as_i64()).unwrap_or(0));
for post in post_list { for post in post_list {
let msg = self.parse_mattermost_post(post, &bot_user_id, last_create_at, &channel_id); let msg =
self.parse_mattermost_post(post, &bot_user_id, last_create_at, &channel_id);
let create_at = post let create_at = post
.get("create_at") .get("create_at")
.and_then(|c| c.as_i64()) .and_then(|c| c.as_i64())
@ -207,7 +206,7 @@ impl MattermostChannel {
let reply_target = if !root_id.is_empty() { let reply_target = if !root_id.is_empty() {
format!("{}:{}", channel_id, root_id) format!("{}:{}", channel_id, root_id)
} else { } else {
// Or if it's a top-level message that WE want to start a thread on, // Or if it's a top-level message that WE want to start a thread on,
// the next reply will use THIS post's ID as root_id. // the next reply will use THIS post's ID as root_id.
// But for now, we follow Mattermost's 'reply' convention where // But for now, we follow Mattermost's 'reply' convention where
// replying to a post uses its ID as root_id. // replying to a post uses its ID as root_id.