mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 18:36:30 +03:00
update chat/contact data only when there was no newer update (#2642)
* check update timestamps for signatures, user-avatars, ephemeral-settings, last-subject * check update timestamp for group-avatars * check update timestamp for group-names * check update timestamp for memberlist * check update timestamp for protection-settings * add a more advanced test * add another more advanced test * set last-subject-timestamp more carefully * bubble up errros from set_*timestamp() and check for from_id==0 before * simplify Params::set_i64() * remove comment that is more confusing than helpful * use update_timestamp() wording consistently
This commit is contained in:
32
src/param.rs
32
src/param.rs
@@ -139,6 +139,27 @@ pub enum Param {
|
||||
|
||||
/// For MDN-sending job
|
||||
MsgId = b'I',
|
||||
|
||||
/// For Contacts: timestamp of status (aka signature or footer) update.
|
||||
StatusTimestamp = b'j',
|
||||
|
||||
/// For Contacts and Chats: timestamp of avatar update.
|
||||
AvatarTimestamp = b'J',
|
||||
|
||||
/// For Chats: timestamp of status/signature/footer update.
|
||||
EphemeralSettingsTimestamp = b'B',
|
||||
|
||||
/// For Chats: timestamp of subject update.
|
||||
SubjectTimestamp = b'C',
|
||||
|
||||
/// For Chats: timestamp of group name update.
|
||||
GroupNameTimestamp = b'g',
|
||||
|
||||
/// For Chats: timestamp of group name update.
|
||||
MemberListTimestamp = b'k',
|
||||
|
||||
/// For Chats: timestamp of protection settings update.
|
||||
ProtectionSettingsTimestamp = b'L',
|
||||
}
|
||||
|
||||
/// An object for handling key=value parameter lists.
|
||||
@@ -245,6 +266,11 @@ impl Params {
|
||||
self.get(key).and_then(|s| s.parse().ok())
|
||||
}
|
||||
|
||||
/// Get the given parameter and parse as `i64`.
|
||||
pub fn get_i64(&self, key: Param) -> Option<i64> {
|
||||
self.get(key).and_then(|s| s.parse().ok())
|
||||
}
|
||||
|
||||
/// Get the given parameter and parse as `bool`.
|
||||
pub fn get_bool(&self, key: Param) -> Option<bool> {
|
||||
self.get_int(key).map(|v| v != 0)
|
||||
@@ -346,6 +372,12 @@ impl Params {
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the given paramter to the passed in `i64`.
|
||||
pub fn set_i64(&mut self, key: Param, value: i64) -> &mut Self {
|
||||
self.set(key, value.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the given parameter to the passed in `f64` .
|
||||
pub fn set_float(&mut self, key: Param, value: f64) -> &mut Self {
|
||||
self.set(key, format!("{}", value));
|
||||
|
||||
Reference in New Issue
Block a user