prevent empty transactions from going out
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -350,7 +350,9 @@ impl Service {
|
|||||||
vec![(event, key)],
|
vec![(event, key)],
|
||||||
&mut current_transaction_status,
|
&mut current_transaction_status,
|
||||||
) {
|
) {
|
||||||
futures.push(handle_events(outgoing_kind, events));
|
if !events.is_empty() {
|
||||||
|
futures.push(handle_events(outgoing_kind, events));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,6 +600,7 @@ pub fn select_edus_receipts(
|
|||||||
async fn handle_events(
|
async fn handle_events(
|
||||||
kind: OutgoingKind, events: Vec<SendingEventType>,
|
kind: OutgoingKind, events: Vec<SendingEventType>,
|
||||||
) -> Result<OutgoingKind, (OutgoingKind, Error)> {
|
) -> Result<OutgoingKind, (OutgoingKind, Error)> {
|
||||||
|
debug_assert!(!events.is_empty(), "sending empty transaction");
|
||||||
match kind {
|
match kind {
|
||||||
OutgoingKind::Appservice(ref id) => handle_events_kind_appservice(&kind, id, events).await,
|
OutgoingKind::Appservice(ref id) => handle_events_kind_appservice(&kind, id, events).await,
|
||||||
OutgoingKind::Push(ref userid, ref pushkey) => handle_events_kind_push(&kind, userid, pushkey, events).await,
|
OutgoingKind::Push(ref userid, ref pushkey) => handle_events_kind_push(&kind, userid, pushkey, events).await,
|
||||||
@@ -638,6 +641,7 @@ async fn handle_events_kind_appservice(
|
|||||||
|
|
||||||
let permit = services().sending.maximum_requests.acquire().await;
|
let permit = services().sending.maximum_requests.acquire().await;
|
||||||
|
|
||||||
|
debug_assert!(!pdu_jsons.is_empty(), "sending empty transaction");
|
||||||
let response = match appservice::send_request(
|
let response = match appservice::send_request(
|
||||||
services()
|
services()
|
||||||
.appservice
|
.appservice
|
||||||
@@ -792,6 +796,7 @@ async fn handle_events_kind_normal(
|
|||||||
|
|
||||||
let permit = services().sending.maximum_requests.acquire().await;
|
let permit = services().sending.maximum_requests.acquire().await;
|
||||||
let client = &services().globals.client.sender;
|
let client = &services().globals.client.sender;
|
||||||
|
debug_assert!(pdu_jsons.len() + edu_jsons.len() > 0, "sending empty transaction");
|
||||||
let response = send::send_request(
|
let response = send::send_request(
|
||||||
client,
|
client,
|
||||||
dest,
|
dest,
|
||||||
|
|||||||
Reference in New Issue
Block a user