mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
introduce DC_EVENT_NEW_BLOB_FILE event and test for it
This commit is contained in:
@@ -3924,6 +3924,16 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot);
|
|||||||
*/
|
*/
|
||||||
#define DC_EVENT_IMAP_MESSAGE_MOVED 105
|
#define DC_EVENT_IMAP_MESSAGE_MOVED 105
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when a new blob file was successfully written
|
||||||
|
*
|
||||||
|
* @param data1 0
|
||||||
|
* @param data2 (const char*) path name
|
||||||
|
* Must not be free()'d or modified and is valid only until the callback returns.
|
||||||
|
* @return 0
|
||||||
|
*/
|
||||||
|
#define DC_EVENT_NEW_BLOB_FILE 150
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The library-user should write a warning string to the log.
|
* The library-user should write a warning string to the log.
|
||||||
* Passed to the callback given to dc_context_new().
|
* Passed to the callback given to dc_context_new().
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ impl ContextWrapper {
|
|||||||
| Event::SmtpMessageSent(msg)
|
| Event::SmtpMessageSent(msg)
|
||||||
| Event::ImapMessageDeleted(msg)
|
| Event::ImapMessageDeleted(msg)
|
||||||
| Event::ImapMessageMoved(msg)
|
| Event::ImapMessageMoved(msg)
|
||||||
|
| Event::NewBlobFile(msg)
|
||||||
| Event::Warning(msg)
|
| Event::Warning(msg)
|
||||||
| Event::Error(msg)
|
| Event::Error(msg)
|
||||||
| Event::ErrorNetwork(msg)
|
| Event::ErrorNetwork(msg)
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ DC_EVENT_IMAP_CONNECTED = 102
|
|||||||
DC_EVENT_SMTP_MESSAGE_SENT = 103
|
DC_EVENT_SMTP_MESSAGE_SENT = 103
|
||||||
DC_EVENT_IMAP_MESSAGE_DELETED = 104
|
DC_EVENT_IMAP_MESSAGE_DELETED = 104
|
||||||
DC_EVENT_IMAP_MESSAGE_MOVED = 105
|
DC_EVENT_IMAP_MESSAGE_MOVED = 105
|
||||||
|
DC_EVENT_NEW_BLOB_FILE = 150
|
||||||
DC_EVENT_WARNING = 300
|
DC_EVENT_WARNING = 300
|
||||||
DC_EVENT_ERROR = 400
|
DC_EVENT_ERROR = 400
|
||||||
DC_EVENT_ERROR_NETWORK = 401
|
DC_EVENT_ERROR_NETWORK = 401
|
||||||
|
|||||||
@@ -229,7 +229,9 @@ class TestOfflineChat:
|
|||||||
chat1.send_image(path="notexists")
|
chat1.send_image(path="notexists")
|
||||||
fn = data.get_path("d.png")
|
fn = data.get_path("d.png")
|
||||||
lp.sec("sending image")
|
lp.sec("sending image")
|
||||||
|
chat1.account._evlogger.consume_events()
|
||||||
msg = chat1.send_image(fn)
|
msg = chat1.send_image(fn)
|
||||||
|
chat1.account._evlogger.get_matching("DC_EVENT_NEW_BLOB_FILE")
|
||||||
assert msg.is_image()
|
assert msg.is_image()
|
||||||
assert msg
|
assert msg
|
||||||
assert msg.id > 0
|
assert msg.id > 0
|
||||||
|
|||||||
@@ -208,7 +208,9 @@ impl Context {
|
|||||||
.open(&path)
|
.open(&path)
|
||||||
{
|
{
|
||||||
file.write_all(data)?;
|
file.write_all(data)?;
|
||||||
return Ok(format!("$BLOBDIR/{}", candidate_basename));
|
let db_entry = format!("$BLOBDIR/{}", candidate_basename);
|
||||||
|
self.call_cb(Event::NewBlobFile(db_entry.clone()));
|
||||||
|
return Ok(db_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bail!("out of luck to create new blob file");
|
bail!("out of luck to create new blob file");
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ pub enum Event {
|
|||||||
#[strum(props(id = "105"))]
|
#[strum(props(id = "105"))]
|
||||||
ImapMessageMoved(String),
|
ImapMessageMoved(String),
|
||||||
|
|
||||||
|
/// Emitted when an new file in the $BLOBDIR was created
|
||||||
|
///
|
||||||
|
/// @return 0
|
||||||
|
#[strum(props(id = "150"))]
|
||||||
|
NewBlobFile(String),
|
||||||
|
|
||||||
/// The library-user should write a warning string to the log.
|
/// The library-user should write a warning string to the log.
|
||||||
/// Passed to the callback given to dc_context_new().
|
/// Passed to the callback given to dc_context_new().
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -947,7 +947,6 @@ fn add_smtp_job(context: &Context, action: Action, mimefactory: &MimeFactory) ->
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
let bpath = context.new_blob_file(&mimefactory.rfc724_mid, bytes)?;
|
let bpath = context.new_blob_file(&mimefactory.rfc724_mid, bytes)?;
|
||||||
info!(context, "add_smtp_job file written: {:?}", bpath);
|
|
||||||
let recipients = mimefactory.recipients_addr.join("\x1e");
|
let recipients = mimefactory.recipients_addr.join("\x1e");
|
||||||
param.set(Param::File, &bpath);
|
param.set(Param::File, &bpath);
|
||||||
param.set(Param::Recipients, &recipients);
|
param.set(Param::Recipients, &recipients);
|
||||||
|
|||||||
Reference in New Issue
Block a user