crypto: Simplify counting the number of messages a to-device request has
This commit is contained in:
parent
880818a588
commit
75ac29540d
2 changed files with 15 additions and 3 deletions
|
@ -63,6 +63,14 @@ impl ToDeviceRequest {
|
|||
pub fn txn_id_string(&self) -> String {
|
||||
self.txn_id.to_string()
|
||||
}
|
||||
|
||||
/// Get the number of unique messages this request contains.
|
||||
///
|
||||
/// *Note*: A single message may be sent to multiple devices, so this may or
|
||||
/// may not be the number of devices that will receive the messages as well.
|
||||
pub fn message_count(&self) -> usize {
|
||||
self.messages.values().map(|d| d.len()).sum()
|
||||
}
|
||||
}
|
||||
|
||||
/// Request that will publish a cross signing identity.
|
||||
|
|
|
@ -251,6 +251,12 @@ impl GroupSessionManager {
|
|||
messages,
|
||||
};
|
||||
|
||||
trace!(
|
||||
recipient_count = request.message_count(),
|
||||
transaction_id = ?id,
|
||||
"Created a to-device request carrying a room_key"
|
||||
);
|
||||
|
||||
Ok((id, request, changed_sessions))
|
||||
}
|
||||
|
||||
|
@ -593,9 +599,7 @@ mod test {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let event_count = requests.iter().fold(0, |acc, r| {
|
||||
acc + r.messages.values().fold(0, |acc, v| acc + v.len())
|
||||
});
|
||||
let event_count: usize = requests.iter().map(|r| r.message_count()).sum();
|
||||
|
||||
// The keys claim response has a couple of one-time keys with invalid
|
||||
// signatures, thus only 148 sessions are actually created, we check
|
||||
|
|
Loading…
Reference in a new issue