mirror of
https://github.com/signalapp/libsignal.git
synced 2024-09-20 20:03:07 +02:00
Merge pull request #237 from signalapp/jack/has-current-state
Fix Node SessionRecord accessor funnctions
This commit is contained in:
commit
b3efdd4b1d
@ -692,6 +692,17 @@ describe('SignalClient', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert.deepEqual(aDPlaintext, bMessage);
|
assert.deepEqual(aDPlaintext, bMessage);
|
||||||
|
|
||||||
|
const session = await bSess.getSession(aAddress);
|
||||||
|
|
||||||
|
if (session != null) {
|
||||||
|
assert(session.serialize().length > 0);
|
||||||
|
assert.deepEqual(session.localRegistrationId(), 5);
|
||||||
|
assert.deepEqual(session.remoteRegistrationId(), 5);
|
||||||
|
assert(session.hasCurrentState());
|
||||||
|
session.archiveCurrentState();
|
||||||
|
assert(!session.hasCurrentState());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
it('SealedSender', async () => {
|
it('SealedSender', async () => {
|
||||||
const aKeys = new InMemoryIdentityKeyStore();
|
const aKeys = new InMemoryIdentityKeyStore();
|
||||||
|
@ -137,7 +137,7 @@ macro_rules! ffi_bridge_deserialize {
|
|||||||
return Err(ffi::SignalFfiError::NullPointer);
|
return Err(ffi::SignalFfiError::NullPointer);
|
||||||
}
|
}
|
||||||
let data = std::slice::from_raw_parts(data, data_len);
|
let data = std::slice::from_raw_parts(data, data_len);
|
||||||
ffi::box_object(p, $typ::$fn(data))
|
ffi::write_result_to(p, $typ::$fn(data))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ macro_rules! jni_bridge_deserialize {
|
|||||||
) -> jni::ObjectHandle {
|
) -> jni::ObjectHandle {
|
||||||
jni::run_ffi_safe(&env, || {
|
jni::run_ffi_safe(&env, || {
|
||||||
let data = env.convert_byte_array(data)?;
|
let data = env.convert_byte_array(data)?;
|
||||||
jni::box_object($typ::$fn(data.as_ref()))
|
jni::ResultTypeInfo::convert_into($typ::$fn(data.as_ref()), &env)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -773,21 +773,23 @@ macro_rules! node_bridge_handle {
|
|||||||
impl<'storage, 'context: 'storage> node::ArgTypeInfo<'storage, 'context>
|
impl<'storage, 'context: 'storage> node::ArgTypeInfo<'storage, 'context>
|
||||||
for &'storage mut $typ
|
for &'storage mut $typ
|
||||||
{
|
{
|
||||||
type ArgType = node::DefaultJsBox<std::cell::RefCell<$typ>>;
|
type ArgType = node::JsObject;
|
||||||
type StoredType = (
|
type StoredType = (
|
||||||
node::Handle<'context, Self::ArgType>,
|
node::Handle<'context, node::DefaultJsBox<std::cell::RefCell<$typ>>>,
|
||||||
std::cell::RefMut<'context, $typ>,
|
std::cell::RefMut<'context, $typ>,
|
||||||
);
|
);
|
||||||
fn borrow(
|
fn borrow(
|
||||||
_cx: &mut node::FunctionContext,
|
cx: &mut node::FunctionContext<'context>,
|
||||||
foreign: node::Handle<'context, Self::ArgType>,
|
foreign: node::Handle<'context, Self::ArgType>,
|
||||||
) -> node::NeonResult<Self::StoredType> {
|
) -> node::NeonResult<Self::StoredType> {
|
||||||
let cell: &std::cell::RefCell<_> = &***foreign;
|
let boxed_value: node::Handle<'context, node::DefaultJsBox<std::cell::RefCell<$typ>>> =
|
||||||
|
node::Object::get(*foreign, cx, node::NATIVE_HANDLE_PROPERTY)?.downcast_or_throw(cx)?;
|
||||||
|
let cell: &std::cell::RefCell<_> = &***boxed_value;
|
||||||
// See above.
|
// See above.
|
||||||
let cell_with_extended_lifetime: &'context std::cell::RefCell<_> = unsafe {
|
let cell_with_extended_lifetime: &'context std::cell::RefCell<_> = unsafe {
|
||||||
node::extend_lifetime(cell)
|
node::extend_lifetime(cell)
|
||||||
};
|
};
|
||||||
Ok((foreign, cell_with_extended_lifetime.borrow_mut()))
|
Ok((boxed_value, cell_with_extended_lifetime.borrow_mut()))
|
||||||
}
|
}
|
||||||
fn load_from(
|
fn load_from(
|
||||||
stored: &'storage mut Self::StoredType,
|
stored: &'storage mut Self::StoredType,
|
||||||
|
@ -135,7 +135,7 @@ macro_rules! node_bridge_deserialize {
|
|||||||
let buffer = cx.argument::<node::JsBuffer>(0)?;
|
let buffer = cx.argument::<node::JsBuffer>(0)?;
|
||||||
let obj: Result<$typ> =
|
let obj: Result<$typ> =
|
||||||
node::with_buffer_contents(&mut cx, buffer, |buf| $typ::$fn(buf));
|
node::with_buffer_contents(&mut cx, buffer, |buf| $typ::$fn(buf));
|
||||||
node::return_boxed_object(&mut cx, obj)
|
node::ResultTypeInfo::convert_into(obj, &mut cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
node_register!([<$node_name _Deserialize>]);
|
node_register!([<$node_name _Deserialize>]);
|
||||||
|
@ -7,6 +7,7 @@ use super::*;
|
|||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use signal_neon_futures::*;
|
use signal_neon_futures::*;
|
||||||
|
use std::cell::RefCell;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct NodePreKeyStore {
|
pub struct NodePreKeyStore {
|
||||||
@ -257,8 +258,8 @@ impl NodeSessionStore {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
})
|
})
|
||||||
.then(|cx, result| match result {
|
.then(|cx, result| match result {
|
||||||
Ok(value) => match value.downcast::<DefaultJsBox<SessionRecord>, _>(cx) {
|
Ok(value) => match value.downcast::<DefaultJsBox<RefCell<SessionRecord>>, _>(cx) {
|
||||||
Ok(obj) => Ok(Some((***obj).clone())),
|
Ok(obj) => Ok(Some((***obj).borrow().clone())),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
if value.is_a::<JsNull, _>(cx) || value.is_a::<JsUndefined, _>(cx) {
|
if value.is_a::<JsNull, _>(cx) || value.is_a::<JsUndefined, _>(cx) {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
Loading…
Reference in New Issue
Block a user