Browse Source

log correct group in client receipts

Justin Tracey 1 year ago
parent
commit
cec6328019
1 changed files with 15 additions and 5 deletions
  1. 15 5
      src/bin/messenger/state.rs

+ 15 - 5
src/bin/messenger/state.rs

@@ -284,7 +284,7 @@ async fn receive_action<
     conversation: Conversation<T>,
     stream_map: &mut M,
     our_id: &str,
-    p2p: bool,
+    group: Option<&str>,
     rng: &mut Xoshiro256PlusPlus,
 ) -> StateMachine {
     match msg.body {
@@ -300,7 +300,11 @@ async fn receive_action<
                 size
             );
             let stream = stream_map.channel_for(&msg.sender);
-            let recipient = if p2p { msg.group } else { msg.sender };
+            let recipient = if group.is_none() {
+                msg.group
+            } else {
+                msg.sender
+            };
             let m = construct_receipt(our_id.to_string(), recipient);
             stream
                 .channel
@@ -309,10 +313,14 @@ async fn receive_action<
             ret
         }
         mgen::MessageBody::Receipt => {
+            let group = match group {
+                Some(group) => group,
+                None => &msg.group,
+            };
             log!(
                 "{},{},receive,{},{},{},receipt",
                 our_id,
-                msg.group,
+                group,
                 T::NAME,
                 T::NAME,
                 msg.sender
@@ -356,7 +364,8 @@ pub async fn manage_idle_conversation<
             send_action(conversation, stream_map.values(), our_id, group, rng).await
         }
         IdleGroupActions::Receive(msg) => {
-            receive_action(msg, conversation, stream_map, our_id, p2p, rng).await
+            let group = if p2p { None } else { Some(group) };
+            receive_action(msg, conversation, stream_map, our_id, group, rng).await
         }
     }
 }
@@ -394,7 +403,8 @@ pub async fn manage_active_conversation<
             send_action(conversation, stream_map.values(), our_id, group, rng).await
         }
         ActiveGroupActions::Receive(msg) => {
-            receive_action(msg, conversation, stream_map, our_id, p2p, rng).await
+            let group = if p2p { None } else { Some(group) };
+            receive_action(msg, conversation, stream_map, our_id, group, rng).await
         }
         ActiveGroupActions::Idle => StateMachine::Idle(conversation.waited(rng)),
     }