diff --git a/.github/workflows/release-mcp.yml b/.github/workflows/release-mcp.yml index fa144f7e5..1c39482a4 100644 --- a/.github/workflows/release-mcp.yml +++ b/.github/workflows/release-mcp.yml @@ -5,7 +5,6 @@ on: branches: - main - build-test - pull_request: {} jobs: build: diff --git a/c/src/content_context/context.rs b/c/src/content_context/context.rs index 29f8afe00..6a4d44bc0 100644 --- a/c/src/content_context/context.rs +++ b/c/src/content_context/context.rs @@ -6,7 +6,7 @@ use crate::{ async_call::{CAsyncCallback, execute_async}, config::CConfig, content_context::types::{CNewsItemOwned, COwnedTopicOwned, CTopicItemOwned}, - types::{CVec, cstr_array_to_rust, cstr_to_rust}, + types::{CString, CVec, cstr_array_to_rust, cstr_to_rust}, }; /// Content context @@ -120,7 +120,7 @@ pub unsafe extern "C" fn lb_content_context_create_topic( }; let license = if license >= 0 { Some(license) } else { None }; execute_async(callback, ctx, userdata, async move { - let owned = ctx_inner + let id = ctx_inner .create_topic(CreateTopicOptions { title, body, @@ -130,8 +130,7 @@ pub unsafe extern "C" fn lb_content_context_create_topic( license, }) .await?; - let rows: CVec = vec![COwnedTopicOwned::from(owned)].into(); - Ok(rows) + Ok(CString::from(id)) }); } diff --git a/c/src/content_context/types.rs b/c/src/content_context/types.rs index 52f965510..30761e9e9 100644 --- a/c/src/content_context/types.rs +++ b/c/src/content_context/types.rs @@ -2,10 +2,7 @@ use std::os::raw::c_char; use longbridge::content::{NewsItem, OwnedTopic, TopicAuthor, TopicImage, TopicItem}; -use crate::{ - async_call::CAsyncResult, - types::{CString, CVec, ToFFI}, -}; +use crate::types::{CString, CVec, ToFFI}; /// Topic author #[repr(C)] diff --git a/nodejs/src/content/context.rs b/nodejs/src/content/context.rs index 03d528514..15ade5650 100644 --- a/nodejs/src/content/context.rs +++ b/nodejs/src/content/context.rs @@ -42,12 +42,12 @@ impl ContentContext { /// Create a new topic #[napi] - pub async fn create_topic(&self, req: CreateTopicRequest) -> Result { - self.ctx + pub async fn create_topic(&self, req: CreateTopicRequest) -> Result { + Ok(self + .ctx .create_topic(req.into()) .await - .map_err(ErrorNewType)? - .try_into() + .map_err(ErrorNewType)?) } /// Get discussion topics list diff --git a/python/src/content/context.rs b/python/src/content/context.rs index 5a9e54c23..1acf4b0fd 100644 --- a/python/src/content/context.rs +++ b/python/src/content/context.rs @@ -56,8 +56,9 @@ impl ContentContext { tickers: Option>, hashtags: Option>, license: Option, - ) -> PyResult { - self.ctx + ) -> PyResult { + Ok(self + .ctx .create_topic(CreateTopicOptions { title, body, @@ -66,8 +67,7 @@ impl ContentContext { hashtags, license, }) - .map_err(ErrorNewType)? - .try_into() + .map_err(ErrorNewType)?) } /// Get discussion topics list diff --git a/python/src/content/context_async.rs b/python/src/content/context_async.rs index 651a567a6..bcd641316 100644 --- a/python/src/content/context_async.rs +++ b/python/src/content/context_async.rs @@ -65,7 +65,7 @@ impl AsyncContentContext { ) -> PyResult> { let ctx = self.ctx.clone(); pyo3_async_runtimes::tokio::future_into_py(py, async move { - let resp = ctx + Ok(ctx .create_topic(CreateTopicOptions { title, body, @@ -75,8 +75,7 @@ impl AsyncContentContext { license, }) .await - .map_err(ErrorNewType)?; - OwnedTopic::try_from(resp) + .map_err(ErrorNewType)?) }) .map(|b| b.unbind()) } diff --git a/rust/src/blocking/content.rs b/rust/src/blocking/content.rs index 2fb0a94b3..4b20fd332 100644 --- a/rust/src/blocking/content.rs +++ b/rust/src/blocking/content.rs @@ -37,7 +37,7 @@ impl ContentContextSync { } /// Create a new topic - pub fn create_topic(&self, opts: CreateTopicOptions) -> Result { + pub fn create_topic(&self, opts: CreateTopicOptions) -> Result { self.rt .call(move |ctx| async move { ctx.create_topic(opts).await }) } diff --git a/rust/src/content/context.rs b/rust/src/content/context.rs index fbbc0e66d..d48bb1daf 100644 --- a/rust/src/content/context.rs +++ b/rust/src/content/context.rs @@ -46,10 +46,15 @@ impl ContentContext { /// Create a new topic /// /// Path: POST /v1/content/topics - pub async fn create_topic(&self, opts: CreateTopicOptions) -> Result { + pub async fn create_topic(&self, opts: CreateTopicOptions) -> Result { + #[derive(Debug, Deserialize)] + struct TopicId { + id: String, + } + #[derive(Debug, Deserialize)] struct Response { - item: OwnedTopic, + item: TopicId, } Ok(self @@ -61,7 +66,8 @@ impl ContentContext { .send() .await? .0 - .item) + .item + .id) } /// Get discussion topics list