Skip to main content

ncm_api_rs/api/
hug_comment.rs

1use super::Query;
2use crate::error::Result;
3/// 抱一抱评论
4/// 对应 Node.js module/hug_comment.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 抱一抱评论
10    /// 对应 /hug/comment
11    pub async fn hug_comment(&self, query: &Query) -> Result<ApiResponse> {
12        let resource_type = query.get_or("type", "0");
13        let type_prefix = crate::util::config::RESOURCE_TYPE_MAP
14            .get(resource_type.as_str())
15            .copied()
16            .unwrap_or("R_SO_4_");
17        let thread_id = format!("{}{}", type_prefix, query.get_or("sid", "0"));
18        let data = json!({
19            "targetUserId": query.get_or("uid", "0"),
20            "commentId": query.get_or("cid", "0"),
21            "threadId": thread_id
22        });
23        self.request(
24            "/api/v2/resource/comments/hug/listener",
25            data,
26            query.to_option(CryptoType::default()),
27        )
28        .await
29    }
30}