mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-02-10 00:43:09 +00:00
fix: Bug in Inbox id’s
This commit is contained in:
parent
b39b418986
commit
0b31a15b6a
@ -41,9 +41,10 @@ impl Context {
|
||||
.invite_to_private_convo(remote_bundle, content)
|
||||
.unwrap_or_else(|_| todo!("Log/Surface Error"));
|
||||
|
||||
let remote_id = Inbox::inbox_identifier_for_key(remote_bundle.installation_key);
|
||||
let payload_bytes = payloads
|
||||
.into_iter()
|
||||
.map(|p| p.to_envelope(convo.id().to_string()))
|
||||
.map(|p| p.to_envelope(remote_id.clone()))
|
||||
.collect();
|
||||
|
||||
let convo_id = self.add_convo(Box::new(convo));
|
||||
@ -77,8 +78,7 @@ impl Context {
|
||||
|
||||
// TODO: Impl Conversation hinting
|
||||
let convo_id = env.conversation_hint;
|
||||
let enc = EncryptedPayload::decode(payload)?;
|
||||
|
||||
let enc = EncryptedPayload::decode(env.payload)?;
|
||||
match convo_id {
|
||||
c if c == self.inbox.id() => self.dispatch_to_inbox(enc),
|
||||
c if self.store.has(&c) => self.dispatch_to_convo(&c, enc),
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use blake2::{Blake2b512, Digest};
|
||||
use chat_proto::logoschat::encryption::EncryptedPayload;
|
||||
use hex;
|
||||
use prost::Message;
|
||||
@ -43,7 +44,7 @@ impl<'a> std::fmt::Debug for Inbox {
|
||||
|
||||
impl Inbox {
|
||||
pub fn new(ident: Rc<Identity>) -> Self {
|
||||
let local_convo_id = ident.address();
|
||||
let local_convo_id = Self::inbox_identifier_for_key(ident.public_key());
|
||||
Self {
|
||||
ident,
|
||||
local_convo_id,
|
||||
@ -216,6 +217,11 @@ impl Inbox {
|
||||
.get(key)
|
||||
.ok_or_else(|| return ChatError::UnknownEphemeralKey())
|
||||
}
|
||||
|
||||
pub fn inbox_identifier_for_key(pubkey: PublicKey) -> String {
|
||||
// TODO: Implement ID according to spec
|
||||
hex::encode(Blake2b512::digest(pubkey))
|
||||
}
|
||||
}
|
||||
|
||||
impl Id for Inbox {
|
||||
|
||||
@ -50,7 +50,7 @@ impl TryFrom<&[u8]> for Introduction {
|
||||
.map_err(|_| ChatError::InvalidKeyLength)?;
|
||||
let installation_key = PublicKey::from(installation_bytes);
|
||||
|
||||
let ephemeral_bytes: [u8; 32] = hex::decode(parts[1])
|
||||
let ephemeral_bytes: [u8; 32] = hex::decode(parts[2])
|
||||
.map_err(|_| ChatError::BadParsing("ephemeral_key"))?
|
||||
.try_into()
|
||||
.map_err(|_| ChatError::InvalidKeyLength)?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user