feat: pre-messages / next version of download on demand (#7371)

Closes <https://github.com/chatmail/core/issues/7367>

Co-authored-by: iequidoo <dgreshilov@gmail.com>
Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
Simon Laux
2026-01-08 22:14:32 +00:00
committed by GitHub
parent 46bbe5f077
commit 2631745a57
43 changed files with 2843 additions and 1393 deletions

View File

@@ -251,6 +251,13 @@ pub enum Param {
/// For info messages: Contact ID in added or removed to a group.
ContactAddedRemoved = b'5',
/// For (pre-)Message: ViewType of the Post-Message,
/// because pre message is always `Viewtype::Text`.
PostMessageViewtype = b'8',
/// For (pre-)Message: File byte size of Post-Message attachment
PostMessageFileBytes = b'9',
}
/// An object for handling key=value parameter lists.
@@ -441,6 +448,15 @@ impl Params {
}
self
}
/// Merge in parameters from other Params struct,
/// overwriting the keys that are in both
/// with the values from the new Params struct.
pub fn merge_in_params(&mut self, new_params: Self) -> &mut Self {
let mut new_params = new_params;
self.inner.append(&mut new_params.inner);
self
}
}
#[cfg(test)]
@@ -503,4 +519,18 @@ mod tests {
assert_eq!(p.get(Param::Height), Some("14"));
Ok(())
}
#[test]
fn test_merge() -> Result<()> {
let mut p = Params::from_str("w=12\na=5\nh=14")?;
let p2 = Params::from_str("L=1\nh=17")?;
assert_eq!(p.len(), 3);
p.merge_in_params(p2);
assert_eq!(p.len(), 4);
assert_eq!(p.get(Param::Width), Some("12"));
assert_eq!(p.get(Param::Height), Some("17"));
assert_eq!(p.get(Param::Forwarded), Some("5"));
assert_eq!(p.get(Param::IsEdited), Some("1"));
Ok(())
}
}