mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 01:46:34 +03:00
Add Event::ChatAutodeleteTimerModified
This commit is contained in:
@@ -4417,6 +4417,11 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot);
|
||||
*/
|
||||
#define DC_EVENT_CHAT_MODIFIED 2020
|
||||
|
||||
/**
|
||||
* Chat autodelete timer changed.
|
||||
*/
|
||||
#define DC_EVENT_CHAT_AUTODELETE_TIMER_MODIFIED 2021
|
||||
|
||||
|
||||
/**
|
||||
* Contact(s) created, renamed, verified, blocked or deleted.
|
||||
|
||||
@@ -170,6 +170,14 @@ impl ContextWrapper {
|
||||
Event::ChatModified(chat_id) => {
|
||||
ffi_cb(self, event_id, chat_id.to_u32() as uintptr_t, 0);
|
||||
}
|
||||
Event::ChatAutodeleteTimerModified { chat_id, timer } => {
|
||||
ffi_cb(
|
||||
self,
|
||||
event_id,
|
||||
chat_id.to_u32() as uintptr_t,
|
||||
timer as uintptr_t,
|
||||
);
|
||||
}
|
||||
Event::ContactsChanged(id) | Event::LocationChanged(id) => {
|
||||
let id = id.unwrap_or_default();
|
||||
ffi_cb(self, event_id, id as uintptr_t, 0);
|
||||
|
||||
@@ -92,6 +92,7 @@ DC_EVENT_MSG_DELIVERED = 2010
|
||||
DC_EVENT_MSG_FAILED = 2012
|
||||
DC_EVENT_MSG_READ = 2015
|
||||
DC_EVENT_CHAT_MODIFIED = 2020
|
||||
DC_EVENT_CHAT_AUTODELETE_TIMER_MODIFIED = 2021
|
||||
DC_EVENT_CONTACTS_CHANGED = 2030
|
||||
DC_EVENT_LOCATION_CHANGED = 2035
|
||||
DC_EVENT_CONFIGURE_PROGRESS = 2041
|
||||
|
||||
@@ -201,6 +201,31 @@ pub fn dc_receive_imf(
|
||||
};
|
||||
}
|
||||
|
||||
if let Some(value) = mime_parser.get(HeaderDef::AutodeleteTimer) {
|
||||
let timer = match value.parse::<u32>() {
|
||||
Ok(timer) => timer,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
context,
|
||||
"can't parse autodelete timer \"{}\": {}", value, err
|
||||
);
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
match chat::set_autodelete_timer(context, chat_id, timer) {
|
||||
Ok(()) => {
|
||||
context.call_cb(Event::ChatAutodeleteTimerModified { chat_id, timer });
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(
|
||||
context,
|
||||
"failed to modify timer for chat {}: {}", chat_id, err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get user-configured server deletion
|
||||
let delete_server_after = context.get_config_delete_server_after();
|
||||
|
||||
@@ -221,6 +246,19 @@ pub fn dc_receive_imf(
|
||||
}
|
||||
}
|
||||
|
||||
// if we delete we don't need to try moving messages
|
||||
if needs_delete_job && !created_db_entries.is_empty() {
|
||||
job_add(
|
||||
context,
|
||||
Action::DeleteMsgOnImap,
|
||||
created_db_entries[0].1.to_u32() as i32,
|
||||
Params::new(),
|
||||
0,
|
||||
);
|
||||
} else {
|
||||
context.do_heuristics_moves(server_folder.as_ref(), insert_msg_id);
|
||||
}
|
||||
|
||||
info!(
|
||||
context,
|
||||
"received message {} has Message-Id: {}", server_uid, rfc724_mid
|
||||
|
||||
@@ -136,9 +136,16 @@ pub enum Event {
|
||||
/// Or the verify state of a chat has changed.
|
||||
/// See dc_set_chat_name(), dc_set_chat_profile_image(), dc_add_contact_to_chat()
|
||||
/// and dc_remove_contact_from_chat().
|
||||
///
|
||||
/// This event does not include autodelete timer modification, which
|
||||
/// is a separate event.
|
||||
#[strum(props(id = "2020"))]
|
||||
ChatModified(ChatId),
|
||||
|
||||
/// Chat autodelete timer changed.
|
||||
#[strum(props(id = "2021"))]
|
||||
ChatAutodeleteTimerModified { chat_id: ChatId, timer: u32 },
|
||||
|
||||
/// Contact(s) created, renamed, blocked or deleted.
|
||||
///
|
||||
/// @param data1 (int) If set, this is the contact_id of an added contact that should be selected.
|
||||
|
||||
@@ -41,6 +41,7 @@ pub enum HeaderDef {
|
||||
SecureJoinFingerprint,
|
||||
SecureJoinInvitenumber,
|
||||
SecureJoinAuth,
|
||||
AutodeleteTimer,
|
||||
_TestHeader,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use chrono::TimeZone;
|
||||
use lettre_email::{mime, Address, Header, MimeMultipartType, PartBuilder};
|
||||
|
||||
use crate::blob::BlobObject;
|
||||
use crate::chat::{self, Chat};
|
||||
use crate::chat::{self, get_autodelete_timer, Chat};
|
||||
use crate::config::Config;
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
@@ -453,6 +453,14 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
||||
Loaded::MDN { .. } => dc_create_outgoing_rfc724_mid(None, &self.from_addr),
|
||||
};
|
||||
|
||||
let autodelete_timer = get_autodelete_timer(self.context, self.msg.chat_id);
|
||||
if autodelete_timer > 0 {
|
||||
protected_headers.push(Header::new(
|
||||
"Autodelete-Timer".to_string(),
|
||||
autodelete_timer.to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
// we could also store the message-id in the protected headers
|
||||
// which would probably help to survive providers like
|
||||
// Outlook.com or hotmail which mangle the Message-ID.
|
||||
|
||||
Reference in New Issue
Block a user