Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/release-mcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- main
- build-test
pull_request: {}

jobs:
build:
Expand Down
7 changes: 3 additions & 4 deletions c/src/content_context/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -130,8 +130,7 @@ pub unsafe extern "C" fn lb_content_context_create_topic(
license,
})
.await?;
let rows: CVec<COwnedTopicOwned> = vec![COwnedTopicOwned::from(owned)].into();
Ok(rows)
Ok(CString::from(id))
});
}

Expand Down
5 changes: 1 addition & 4 deletions c/src/content_context/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 4 additions & 4 deletions nodejs/src/content/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ impl ContentContext {

/// Create a new topic
#[napi]
pub async fn create_topic(&self, req: CreateTopicRequest) -> Result<OwnedTopic> {
self.ctx
pub async fn create_topic(&self, req: CreateTopicRequest) -> Result<String> {
Ok(self
.ctx
.create_topic(req.into())
.await
.map_err(ErrorNewType)?
.try_into()
.map_err(ErrorNewType)?)
}

/// Get discussion topics list
Expand Down
8 changes: 4 additions & 4 deletions python/src/content/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ impl ContentContext {
tickers: Option<Vec<String>>,
hashtags: Option<Vec<String>>,
license: Option<i32>,
) -> PyResult<OwnedTopic> {
self.ctx
) -> PyResult<String> {
Ok(self
.ctx
.create_topic(CreateTopicOptions {
title,
body,
Expand All @@ -66,8 +67,7 @@ impl ContentContext {
hashtags,
license,
})
.map_err(ErrorNewType)?
.try_into()
.map_err(ErrorNewType)?)
}

/// Get discussion topics list
Expand Down
5 changes: 2 additions & 3 deletions python/src/content/context_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl AsyncContentContext {
) -> PyResult<Py<PyAny>> {
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,
Expand All @@ -75,8 +75,7 @@ impl AsyncContentContext {
license,
})
.await
.map_err(ErrorNewType)?;
OwnedTopic::try_from(resp)
.map_err(ErrorNewType)?)
})
.map(|b| b.unbind())
}
Expand Down
2 changes: 1 addition & 1 deletion rust/src/blocking/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl ContentContextSync {
}

/// Create a new topic
pub fn create_topic(&self, opts: CreateTopicOptions) -> Result<OwnedTopic> {
pub fn create_topic(&self, opts: CreateTopicOptions) -> Result<String> {
self.rt
.call(move |ctx| async move { ctx.create_topic(opts).await })
}
Expand Down
12 changes: 9 additions & 3 deletions rust/src/content/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ impl ContentContext {
/// Create a new topic
///
/// Path: POST /v1/content/topics
pub async fn create_topic(&self, opts: CreateTopicOptions) -> Result<OwnedTopic> {
pub async fn create_topic(&self, opts: CreateTopicOptions) -> Result<String> {
#[derive(Debug, Deserialize)]
struct TopicId {
id: String,
}

#[derive(Debug, Deserialize)]
struct Response {
item: OwnedTopic,
item: TopicId,
}

Ok(self
Expand All @@ -61,7 +66,8 @@ impl ContentContext {
.send()
.await?
.0
.item)
.item
.id)
}

/// Get discussion topics list
Expand Down
Loading