From 02dae0652d860bb25ce2887262bef8ab1806a20e Mon Sep 17 00:00:00 2001
From: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com>
Date: Fri, 6 Feb 2026 08:25:17 -0800
Subject: [PATCH] Cleanup handler for easier understanding
---
conversations/src/context.rs | 39 +++++++++++++++++++++----------
conversations/src/conversation.rs | 4 ++++
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/conversations/src/context.rs b/conversations/src/context.rs
index 8f6f7c2..342e9d2 100644
--- a/conversations/src/context.rs
+++ b/conversations/src/context.rs
@@ -88,21 +88,36 @@ impl Context {
let convo_id = env.conversation_hint;
let enc = EncryptedPayload::decode(payload)?;
- // Call handle_payload on the appropriate protocol.
- if convo_id == self.inbox.id() {
- let (convo, content) = self.inbox.handle_frame(enc)?;
- self.add_convo(convo);
-
- Ok(content)
- } else {
- let Some(convo) = self.store.get_mut(&convo_id) else {
- return Err(ChatError::NoConvo(0)); // TODO: Remove ConvoHandle type
- };
-
- convo.handle_frame(enc)
+ 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),
+ _ => Err(ChatError::NoConvo(0)), // TODO: Remove ConvoHandle type
}
}
+ // Dispatch encrypted payload to Inbox, and register the created Conversation
+ fn dispatch_to_inbox(
+ &mut self,
+ enc_payload: EncryptedPayload,
+ ) -> Result