mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
feat: Limit the size of aggregated WebXDC update to 100 KiB (#4825)
Before, update sending might be delayed due to rate limits and later merged into large messages. This is undesirable for apps that want to send large files over WebXDC updates because the message with aggregated update may be too large for actual sending and hit the provider limit or require multiple attempts on a flaky SMTP connection. So, don't aggregate updates if the size of an aggregated update will exceed the limit of 100 KiB. This is a soft limit, so it may be exceeded if a single update is larger and it limits only the update JSON size, so the message with all envelopes still may be larger. Also the limit may be exceeded when updates are sent together with the WebXDC instance when resending it as the instance size isn't accounted to not complicate the code. At least this is not worse than the previous behaviour when all updates were attached.
This commit is contained in:
@@ -31,6 +31,7 @@ use crate::tools::IsNoneOrEmpty;
|
||||
use crate::tools::{
|
||||
create_outgoing_rfc724_mid, create_smeared_timestamp, remove_subject_prefix, time,
|
||||
};
|
||||
use crate::webxdc::StatusUpdateSerial;
|
||||
use crate::{location, peer_channels};
|
||||
|
||||
// attachments of 25 mb brutto should work on the majority of providers
|
||||
@@ -1369,8 +1370,13 @@ impl MimeFactory {
|
||||
} else if msg.viewtype == Viewtype::Webxdc {
|
||||
let topic = peer_channels::create_random_topic();
|
||||
headers.push(create_iroh_header(context, topic, msg.id).await?);
|
||||
if let Some(json) = context
|
||||
.render_webxdc_status_update_object(msg.id, None)
|
||||
if let (Some(json), _) = context
|
||||
.render_webxdc_status_update_object(
|
||||
msg.id,
|
||||
StatusUpdateSerial::MIN,
|
||||
StatusUpdateSerial::MAX,
|
||||
None,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
parts.push(context.build_status_update_part(&json));
|
||||
|
||||
Reference in New Issue
Block a user