chore: expose isNewConvo property (#57)

This commit is contained in:
osmaczko 2026-02-18 20:01:47 +01:00 committed by GitHub
parent 95ddce9161
commit a9ca4ffb7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View File

@ -226,6 +226,7 @@ pub struct HandlePayloadResult {
pub error_code: i32,
pub convo_id: repr_c::String,
pub content: repr_c::Vec<u8>,
pub is_new_convo: bool,
}
/// Free the result from handle_payload
@ -240,6 +241,7 @@ impl From<ContentData> for HandlePayloadResult {
error_code: ErrorCode::None as i32,
convo_id: value.conversation_id.into(),
content: value.data.into(),
is_new_convo: value.is_new_convo,
}
}
}
@ -253,6 +255,7 @@ impl From<Option<ContentData>> for HandlePayloadResult {
error_code: ErrorCode::None as i32,
convo_id: repr_c::String::EMPTY,
content: repr_c::Vec::EMPTY,
is_new_convo: false,
}
}
}
@ -265,6 +268,7 @@ impl From<ChatError> for HandlePayloadResult {
error_code: ErrorCode::UnknownError as i32,
convo_id: String::EMPTY,
content: repr_c::Vec::EMPTY,
is_new_convo: false,
}
}
}

View File

@ -84,6 +84,7 @@ type
error_code*: int32
convo_id*: ReprCString
content*: VecUint8
is_new_convo*: bool
## Result from create_new_private_convo
## error_code is 0 on success, negative on error (see ErrorCode)

View File

@ -114,6 +114,7 @@ type
ContentResult* = object
conversationId*: string
data*: seq[uint8]
isNewConvo*: bool
## Handle an incoming payload and decrypt content
proc handlePayload*(ctx: LibChat, payload: seq[byte]): Result[Option[ContentResult], string] =
@ -141,5 +142,6 @@ proc handlePayload*(ctx: LibChat, payload: seq[byte]): Result[Option[ContentResu
return ok(some(ContentResult(
conversationId: $res.convo_id,
data: content
data: content,
isNewConvo: res.is_new_convo
)))