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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ build


.DS_Store
*/.DS_Store
*/.DS_Store
*.dylib
18 changes: 6 additions & 12 deletions c/csrc/include/longbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -4013,10 +4013,6 @@ typedef struct lb_owned_topic_t {
* Content type: "article" or "post"
*/
const char *topic_type;
/**
* License: 0=none, 1=original, 2=non-original
*/
int32_t license;
/**
* URL to the full topic page
*/
Expand Down Expand Up @@ -4255,12 +4251,12 @@ void lb_content_context_release(const struct lb_content_context_t *ctx);
* @param callback Async callback
* @param userdata User data passed to the callback
*/
void lb_content_context_topics_mine(const struct lb_content_context_t *ctx,
int32_t page,
int32_t size,
const char *topic_type,
lb_async_callback_t callback,
void *userdata);
void lb_content_context_my_topics(const struct lb_content_context_t *ctx,
int32_t page,
int32_t size,
const char *topic_type,
lb_async_callback_t callback,
void *userdata);

/**
* Create a new topic
Expand All @@ -4273,7 +4269,6 @@ void lb_content_context_topics_mine(const struct lb_content_context_t *ctx,
* @param num_tickers Number of tickers
* @param hashtags Hashtag names array (NULL = none)
* @param num_hashtags Number of hashtags
* @param license 0=none, 1=original, 2=non-original (-1 = default)
* @param callback Async callback
* @param userdata User data passed to the callback
*/
Expand All @@ -4285,7 +4280,6 @@ void lb_content_context_create_topic(const struct lb_content_context_t *ctx,
uintptr_t num_tickers,
const char *const *hashtags,
uintptr_t num_hashtags,
int32_t license,
lb_async_callback_t callback,
void *userdata);

Expand Down
10 changes: 3 additions & 7 deletions c/src/content_context/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{ffi::c_void, os::raw::c_char, sync::Arc};

use longbridge::content::{ContentContext, CreateTopicOptions, ListMyTopicsOptions};
use longbridge::content::{ContentContext, CreateTopicOptions, MyTopicsOptions};

use crate::{
async_call::{CAsyncCallback, execute_async},
Expand Down Expand Up @@ -46,7 +46,7 @@ pub unsafe extern "C" fn lb_content_context_release(ctx: *const CContentContext)
/// @param callback Async callback
/// @param userdata User data passed to the callback
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lb_content_context_topics_mine(
pub unsafe extern "C" fn lb_content_context_my_topics(
ctx: *const CContentContext,
page: i32,
size: i32,
Expand All @@ -62,7 +62,7 @@ pub unsafe extern "C" fn lb_content_context_topics_mine(
};
execute_async(callback, ctx, userdata, async move {
let rows: CVec<COwnedTopicOwned> = ctx_inner
.topics_mine(ListMyTopicsOptions {
.my_topics(MyTopicsOptions {
page: if page > 0 { Some(page) } else { None },
size: if size > 0 { Some(size) } else { None },
topic_type,
Expand All @@ -83,7 +83,6 @@ pub unsafe extern "C" fn lb_content_context_topics_mine(
/// @param num_tickers Number of tickers
/// @param hashtags Hashtag names array (NULL = none)
/// @param num_hashtags Number of hashtags
/// @param license 0=none, 1=original, 2=non-original (-1 = default)
/// @param callback Async callback
/// @param userdata User data passed to the callback
#[unsafe(no_mangle)]
Expand All @@ -96,7 +95,6 @@ pub unsafe extern "C" fn lb_content_context_create_topic(
num_tickers: usize,
hashtags: *const *const c_char,
num_hashtags: usize,
license: i32,
callback: CAsyncCallback,
userdata: *mut c_void,
) {
Expand All @@ -118,7 +116,6 @@ pub unsafe extern "C" fn lb_content_context_create_topic(
} else {
Some(cstr_array_to_rust(hashtags, num_hashtags))
};
let license = if license >= 0 { Some(license) } else { None };
execute_async(callback, ctx, userdata, async move {
let id = ctx_inner
.create_topic(CreateTopicOptions {
Expand All @@ -127,7 +124,6 @@ pub unsafe extern "C" fn lb_content_context_create_topic(
topic_type,
tickers,
hashtags,
license,
})
.await?;
Ok(CString::from(id))
Expand Down
5 changes: 0 additions & 5 deletions c/src/content_context/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ pub struct COwnedTopic {
pub shares_count: i32,
/// Content type: "article" or "post"
pub topic_type: *const c_char,
/// License: 0=none, 1=original, 2=non-original
pub license: i32,
/// URL to the full topic page
pub detail_url: *const c_char,
/// Created time (Unix timestamp)
Expand All @@ -142,7 +140,6 @@ pub(crate) struct COwnedTopicOwned {
views_count: i32,
shares_count: i32,
topic_type: CString,
license: i32,
detail_url: CString,
created_at: i64,
updated_at: i64,
Expand All @@ -164,7 +161,6 @@ impl From<OwnedTopic> for COwnedTopicOwned {
views_count: item.views_count,
shares_count: item.shares_count,
topic_type: item.topic_type.into(),
license: item.license,
detail_url: item.detail_url.into(),
created_at: item.created_at.unix_timestamp(),
updated_at: item.updated_at.unix_timestamp(),
Expand Down Expand Up @@ -192,7 +188,6 @@ impl ToFFI for COwnedTopicOwned {
views_count: self.views_count,
shares_count: self.shares_count,
topic_type: self.topic_type.to_ffi_type(),
license: self.license,
detail_url: self.detail_url.to_ffi_type(),
created_at: self.created_at,
updated_at: self.updated_at,
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/content_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ContentContext
static ContentContext create(const Config& config);

/// Get topics created by the current authenticated user
void topics_mine(const ListMyTopicsOptions& opts,
void my_topics(const MyTopicsOptions& opts,
AsyncCallback<ContentContext, std::vector<OwnedTopic>> callback) const;

/// Create a new topic
Expand Down
6 changes: 1 addition & 5 deletions cpp/include/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,8 +2178,6 @@ struct OwnedTopic
int32_t shares_count;
/// Content type: "article" or "post"
std::string topic_type;
/// License: 0=none, 1=original, 2=non-original
int32_t license;
/// URL to the full topic page
std::string detail_url;
/// Created time (Unix timestamp)
Expand All @@ -2189,7 +2187,7 @@ struct OwnedTopic
};

/// Options for listing topics created by the current authenticated user
struct ListMyTopicsOptions
struct MyTopicsOptions
{
/// Page number (0 = default 1)
int32_t page = 0;
Expand All @@ -2212,8 +2210,6 @@ struct CreateTopicOptions
std::vector<std::string> tickers;
/// Hashtag names, max 5
std::vector<std::string> hashtags;
/// License: 0=none (default), 1=original, 2=non-original (-1 = not set)
int32_t license = -1;
};

} // namespace content
Expand Down
7 changes: 3 additions & 4 deletions cpp/src/content_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ ContentContext::create(const Config& config)
}

void
ContentContext::topics_mine(
const ListMyTopicsOptions& opts,
ContentContext::my_topics(
const MyTopicsOptions& opts,
AsyncCallback<ContentContext, std::vector<OwnedTopic>> callback) const
{
const char* topic_type =
opts.topic_type.empty() ? nullptr : opts.topic_type.c_str();
lb_content_context_topics_mine(
lb_content_context_my_topics(
ctx_,
opts.page,
opts.size,
Expand Down Expand Up @@ -126,7 +126,6 @@ ContentContext::create_topic(
tickers_cstr.size(),
hashtags_cstr.empty() ? nullptr : hashtags_cstr.data(),
hashtags_cstr.size(),
opts.license,
[](auto res) {
auto callback_ptr =
callback::get_async_callback<ContentContext, OwnedTopic>(
Expand Down
1 change: 0 additions & 1 deletion cpp/src/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,6 @@ convert(const lb_owned_topic_t* item)
item->views_count,
item->shares_count,
item->topic_type,
item->license,
item->detail_url,
item->created_at,
item->updated_at };
Expand Down
2 changes: 1 addition & 1 deletion java/javasrc/src/main/java/com/longbridge/SdkNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static native void oauthBuild(String clientId, int callbackPort,

public static native void freeContentContext(long context);

public static native void contentContextTopicsMine(long context, Object opts, AsyncCallback callback);
public static native void contentContextMyTopics(long context, Object opts, AsyncCallback callback);

public static native void contentContextCreateTopic(long context, Object opts, AsyncCallback callback);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public void close() throws Exception {
* @return A Future representing the result of the operation
* @throws OpenApiException If an error occurs
*/
public CompletableFuture<OwnedTopic[]> getTopicsMine(ListMyTopicsOptions opts)
public CompletableFuture<OwnedTopic[]> getMyTopics(MyTopicsOptions opts)
throws OpenApiException {
return AsyncCallback.executeTask((callback) -> {
SdkNative.contentContextTopicsMine(raw, opts, callback);
SdkNative.contentContextMyTopics(raw, opts, callback);
});
}

Expand All @@ -48,7 +48,7 @@ public CompletableFuture<OwnedTopic[]> getTopicsMine(ListMyTopicsOptions opts)
* @return A Future representing the result of the operation
* @throws OpenApiException If an error occurs
*/
public CompletableFuture<OwnedTopic> createTopic(CreateTopicOptions opts)
public CompletableFuture<String> createTopic(CreateTopicOptions opts)
throws OpenApiException {
return AsyncCallback.executeTask((callback) -> {
SdkNative.contentContextCreateTopic(raw, opts, callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class CreateTopicOptions {
private String topicType;
private String[] tickers;
private String[] hashtags;
private Integer license;

/**
* Constructs a create-topic request.
Expand Down Expand Up @@ -56,14 +55,4 @@ public CreateTopicOptions setHashtags(String[] hashtags) {
return this;
}

/**
* Sets the license: 0=none (default), 1=original, 2=non-original.
*
* @param license license value
* @return this instance for chaining
*/
public CreateTopicOptions setLicense(int license) {
this.license = license;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Options for listing topics created by the current authenticated user
*/
@SuppressWarnings("unused")
public class ListMyTopicsOptions {
public class MyTopicsOptions {
private Integer page;
private Integer size;
private String topicType;
Expand All @@ -15,7 +15,7 @@ public class ListMyTopicsOptions {
* @param page page number
* @return this instance for chaining
*/
public ListMyTopicsOptions setPage(int page) {
public MyTopicsOptions setPage(int page) {
this.page = page;
return this;
}
Expand All @@ -26,7 +26,7 @@ public ListMyTopicsOptions setPage(int page) {
* @param size records per page
* @return this instance for chaining
*/
public ListMyTopicsOptions setSize(int size) {
public MyTopicsOptions setSize(int size) {
this.size = size;
return this;
}
Expand All @@ -37,7 +37,7 @@ public ListMyTopicsOptions setSize(int size) {
* @param topicType topic type filter
* @return this instance for chaining
*/
public ListMyTopicsOptions setTopicType(String topicType) {
public MyTopicsOptions setTopicType(String topicType) {
this.topicType = topicType;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class OwnedTopic {
private int viewsCount;
private int sharesCount;
private String topicType;
private int license;
private String detailUrl;
private OffsetDateTime createdAt;
private OffsetDateTime updatedAt;
Expand Down Expand Up @@ -63,9 +62,6 @@ public class OwnedTopic {
/** Returns the content type: "article" or "post". */
public String getTopicType() { return topicType; }

/** Returns the license: 0=none, 1=original, 2=non-original. */
public int getLicense() { return license; }

/** Returns the URL to the full topic page. */
public String getDetailUrl() { return detailUrl; }

Expand Down
8 changes: 3 additions & 5 deletions java/src/content_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use jni::{
};
use longbridge::{
Config,
content::{ContentContext, CreateTopicOptions, ListMyTopicsOptions},
content::{ContentContext, CreateTopicOptions, MyTopicsOptions},
};

use crate::{
Expand Down Expand Up @@ -42,7 +42,7 @@ pub unsafe extern "system" fn Java_com_longbridge_SdkNative_freeContentContext(
}

#[unsafe(no_mangle)]
pub unsafe extern "system" fn Java_com_longbridge_SdkNative_contentContextTopicsMine(
pub unsafe extern "system" fn Java_com_longbridge_SdkNative_contentContextMyTopics(
mut env: JNIEnv,
_class: JClass,
context: i64,
Expand All @@ -58,7 +58,7 @@ pub unsafe extern "system" fn Java_com_longbridge_SdkNative_contentContextTopics
Ok(ObjectArray(
context
.ctx
.topics_mine(ListMyTopicsOptions {
.my_topics(MyTopicsOptions {
page: page.map(i32::from),
size: size.map(i32::from),
topic_type,
Expand All @@ -85,7 +85,6 @@ pub unsafe extern "system" fn Java_com_longbridge_SdkNative_contentContextCreate
let topic_type: Option<String> = get_field(env, &opts, "topicType")?;
let tickers: Option<ObjectArray<String>> = get_field(env, &opts, "tickers")?;
let hashtags: Option<ObjectArray<String>> = get_field(env, &opts, "hashtags")?;
let license: Option<JavaInteger> = get_field(env, &opts, "license")?;
async_util::execute(env, callback, async move {
Ok(context
.ctx
Expand All @@ -95,7 +94,6 @@ pub unsafe extern "system" fn Java_com_longbridge_SdkNative_contentContextCreate
topic_type,
tickers: tickers.map(|a| a.0),
hashtags: hashtags.map(|a| a.0),
license: license.map(i32::from),
})
.await?)
})?;
Expand Down
1 change: 0 additions & 1 deletion java/src/types/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ impl_java_class!(
views_count,
shares_count,
topic_type,
license,
detail_url,
created_at,
updated_at
Expand Down
Loading
Loading