mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
clippy: fix needless_borrow
This commit is contained in:
@@ -58,7 +58,7 @@ impl<'a> BlobObject<'a> {
|
|||||||
) -> std::result::Result<BlobObject<'a>, BlobError> {
|
) -> std::result::Result<BlobObject<'a>, BlobError> {
|
||||||
let blobdir = context.get_blobdir();
|
let blobdir = context.get_blobdir();
|
||||||
let (stem, ext) = BlobObject::sanitise_name(suggested_name.as_ref());
|
let (stem, ext) = BlobObject::sanitise_name(suggested_name.as_ref());
|
||||||
let (name, mut file) = BlobObject::create_new_file(&blobdir, &stem, &ext).await?;
|
let (name, mut file) = BlobObject::create_new_file(blobdir, &stem, &ext).await?;
|
||||||
file.write_all(data)
|
file.write_all(data)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| BlobError::WriteFailure {
|
.map_err(|err| BlobError::WriteFailure {
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ impl ChatId {
|
|||||||
if chat.is_self_talk() {
|
if chat.is_self_talk() {
|
||||||
let mut msg = Message::new(Viewtype::Text);
|
let mut msg = Message::new(Viewtype::Text);
|
||||||
msg.text = Some(stock_str::self_deleted_msg_body(context).await);
|
msg.text = Some(stock_str::self_deleted_msg_body(context).await);
|
||||||
add_device_msg(&context, None, Some(&mut msg)).await?;
|
add_device_msg(context, None, Some(&mut msg)).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ impl Context {
|
|||||||
.await?;
|
.await?;
|
||||||
match value {
|
match value {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let blob = BlobObject::new_from_path(&self, value).await?;
|
let blob = BlobObject::new_from_path(self, value).await?;
|
||||||
blob.recode_to_avatar_size(self).await?;
|
blob.recode_to_avatar_size(self).await?;
|
||||||
self.sql
|
self.sql
|
||||||
.set_raw_config(self, key, Some(blob.as_name()))
|
.set_raw_config(self, key, Some(blob.as_name()))
|
||||||
@@ -344,7 +344,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let avatar_blob = t.get_blobdir().join("avatar.jpg");
|
let avatar_blob = t.get_blobdir().join("avatar.jpg");
|
||||||
assert!(!avatar_blob.exists().await);
|
assert!(!avatar_blob.exists().await);
|
||||||
t.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
t.set_config(Config::Selfavatar, Some(avatar_src.to_str().unwrap()))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(avatar_blob.exists().await);
|
assert!(avatar_blob.exists().await);
|
||||||
@@ -375,7 +375,7 @@ mod tests {
|
|||||||
assert_eq!(img.width(), 900);
|
assert_eq!(img.width(), 900);
|
||||||
assert_eq!(img.height(), 900);
|
assert_eq!(img.height(), 900);
|
||||||
|
|
||||||
t.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
t.set_config(Config::Selfavatar, Some(avatar_src.to_str().unwrap()))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let avatar_cfg = t.get_config(Config::Selfavatar).await;
|
let avatar_cfg = t.get_config(Config::Selfavatar).await;
|
||||||
@@ -397,7 +397,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let avatar_blob = t.get_blobdir().join("avatar.png");
|
let avatar_blob = t.get_blobdir().join("avatar.png");
|
||||||
assert!(!avatar_blob.exists().await);
|
assert!(!avatar_blob.exists().await);
|
||||||
t.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
t.set_config(Config::Selfavatar, Some(avatar_src.to_str().unwrap()))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(avatar_blob.exists().await);
|
assert!(avatar_blob.exists().await);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ fn parse_protocol<B: BufRead>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Text(ref e) => {
|
Event::Text(ref e) => {
|
||||||
let val = e.unescape_and_decode(&reader).unwrap_or_default();
|
let val = e.unescape_and_decode(reader).unwrap_or_default();
|
||||||
|
|
||||||
if let Some(ref tag) = current_tag {
|
if let Some(ref tag) = current_tag {
|
||||||
match tag.as_str() {
|
match tag.as_str() {
|
||||||
@@ -117,7 +117,7 @@ fn parse_redirecturl<B: BufRead>(
|
|||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
match reader.read_event(&mut buf)? {
|
match reader.read_event(&mut buf)? {
|
||||||
Event::Text(ref e) => {
|
Event::Text(ref e) => {
|
||||||
let val = e.unescape_and_decode(&reader).unwrap_or_default();
|
let val = e.unescape_and_decode(reader).unwrap_or_default();
|
||||||
Ok(val.trim().to_string())
|
Ok(val.trim().to_string())
|
||||||
}
|
}
|
||||||
_ => Ok("".to_string()),
|
_ => Ok("".to_string()),
|
||||||
@@ -154,7 +154,7 @@ fn parse_xml_reader<B: BufRead>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_xml(xml_raw: &str) -> Result<ParsingResult, Error> {
|
fn parse_xml(xml_raw: &str) -> Result<ParsingResult, Error> {
|
||||||
let mut reader = quick_xml::Reader::from_str(&xml_raw);
|
let mut reader = quick_xml::Reader::from_str(xml_raw);
|
||||||
reader.trim_text(true);
|
reader.trim_text(true);
|
||||||
|
|
||||||
parse_xml_reader(&mut reader).map_err(|error| Error::InvalidXml {
|
parse_xml_reader(&mut reader).map_err(|error| Error::InvalidXml {
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ async fn get_autoconfig(
|
|||||||
"https://autoconfig.{}/mail/config-v1.1.xml?emailaddress={}",
|
"https://autoconfig.{}/mail/config-v1.1.xml?emailaddress={}",
|
||||||
param_domain, param_addr_urlencoded
|
param_domain, param_addr_urlencoded
|
||||||
),
|
),
|
||||||
¶m,
|
param,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@@ -465,7 +465,7 @@ async fn get_autoconfig(
|
|||||||
"https://{}/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress={}",
|
"https://{}/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress={}",
|
||||||
¶m_domain, ¶m_addr_urlencoded
|
¶m_domain, ¶m_addr_urlencoded
|
||||||
),
|
),
|
||||||
¶m,
|
param,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@@ -501,7 +501,7 @@ async fn get_autoconfig(
|
|||||||
if let Ok(res) = moz_autoconfigure(
|
if let Ok(res) = moz_autoconfigure(
|
||||||
ctx,
|
ctx,
|
||||||
format!("https://autoconfig.thunderbird.net/v1.1/{}", ¶m_domain),
|
format!("https://autoconfig.thunderbird.net/v1.1/{}", ¶m_domain),
|
||||||
¶m,
|
param,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1328,7 +1328,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_split_address_book() {
|
fn test_split_address_book() {
|
||||||
let book = "Name one\nAddress one\nName two\nAddress two\nrest name";
|
let book = "Name one\nAddress one\nName two\nAddress two\nrest name";
|
||||||
let list = split_address_book(&book);
|
let list = split_address_book(book);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
list,
|
list,
|
||||||
vec![("Name one", "Address one"), ("Name two", "Address two")]
|
vec![("Name one", "Address one"), ("Name two", "Address two")]
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ pub(crate) async fn dc_receive_imf_inner(
|
|||||||
|
|
||||||
if let Some(avatar_action) = &mime_parser.user_avatar {
|
if let Some(avatar_action) = &mime_parser.user_avatar {
|
||||||
match contact::set_profile_image(
|
match contact::set_profile_image(
|
||||||
&context,
|
context,
|
||||||
from_id,
|
from_id,
|
||||||
avatar_action,
|
avatar_action,
|
||||||
mime_parser.was_encrypted(),
|
mime_parser.was_encrypted(),
|
||||||
@@ -239,7 +239,7 @@ pub(crate) async fn dc_receive_imf_inner(
|
|||||||
|
|
||||||
// Always update the status, even if there is no footer, to allow removing the status.
|
// Always update the status, even if there is no footer, to allow removing the status.
|
||||||
if let Err(err) = contact::set_status(
|
if let Err(err) = contact::set_status(
|
||||||
&context,
|
context,
|
||||||
from_id,
|
from_id,
|
||||||
mime_parser.footer.clone().unwrap_or_default(),
|
mime_parser.footer.clone().unwrap_or_default(),
|
||||||
)
|
)
|
||||||
@@ -387,10 +387,10 @@ async fn add_parts(
|
|||||||
// (if the mail was moved around) and finish. (we may get a mail twice eg. if it is
|
// (if the mail was moved around) and finish. (we may get a mail twice eg. if it is
|
||||||
// moved between folders. make sure, this check is done eg. before securejoin-processing) */
|
// moved between folders. make sure, this check is done eg. before securejoin-processing) */
|
||||||
if let Some((old_server_folder, old_server_uid, _)) =
|
if let Some((old_server_folder, old_server_uid, _)) =
|
||||||
message::rfc724_mid_exists(context, &rfc724_mid).await?
|
message::rfc724_mid_exists(context, rfc724_mid).await?
|
||||||
{
|
{
|
||||||
if old_server_folder != server_folder.as_ref() || old_server_uid != server_uid {
|
if old_server_folder != server_folder.as_ref() || old_server_uid != server_uid {
|
||||||
message::update_server_uid(context, &rfc724_mid, server_folder.as_ref(), server_uid)
|
message::update_server_uid(context, rfc724_mid, server_folder.as_ref(), server_uid)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1870,13 +1870,13 @@ async fn get_parent_message(
|
|||||||
mime_parser: &MimeMessage,
|
mime_parser: &MimeMessage,
|
||||||
) -> Result<Option<Message>> {
|
) -> Result<Option<Message>> {
|
||||||
if let Some(field) = mime_parser.get(HeaderDef::References) {
|
if let Some(field) = mime_parser.get(HeaderDef::References) {
|
||||||
if let Some(msg) = get_rfc724_mid_in_list(context, &field).await? {
|
if let Some(msg) = get_rfc724_mid_in_list(context, field).await? {
|
||||||
return Ok(Some(msg));
|
return Ok(Some(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(field) = mime_parser.get(HeaderDef::InReplyTo) {
|
if let Some(field) = mime_parser.get(HeaderDef::InReplyTo) {
|
||||||
if let Some(msg) = get_rfc724_mid_in_list(context, &field).await? {
|
if let Some(msg) = get_rfc724_mid_in_list(context, field).await? {
|
||||||
return Ok(Some(msg));
|
return Ok(Some(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2643,12 +2643,12 @@ mod tests {
|
|||||||
.set_config(Config::ShowEmails, Some("2"))
|
.set_config(Config::ShowEmails, Some("2"))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
dc_receive_imf(&context, imf_raw, "INBOX", 0, false)
|
dc_receive_imf(context, imf_raw, "INBOX", 0, false)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let chats = Chatlist::try_load(&context, 0, None, None).await.unwrap();
|
let chats = Chatlist::try_load(context, 0, None, None).await.unwrap();
|
||||||
let msg_id = chats.get_msg_id(0).unwrap();
|
let msg_id = chats.get_msg_id(0).unwrap();
|
||||||
Message::load_from_db(&context, msg_id).await.unwrap()
|
Message::load_from_db(context, msg_id).await.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ pub async fn try_decrypt(
|
|||||||
let from = mail
|
let from = mail
|
||||||
.headers
|
.headers
|
||||||
.get_header(HeaderDef::From_)
|
.get_header(HeaderDef::From_)
|
||||||
.and_then(|from_addr| mailparse::addrparse_header(&from_addr).ok())
|
.and_then(|from_addr| mailparse::addrparse_header(from_addr).ok())
|
||||||
.and_then(|from| from.extract_single_info())
|
.and_then(|from| from.extract_single_info())
|
||||||
.map(|from| from.addr)
|
.map(|from| from.addr)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
@@ -163,7 +163,7 @@ pub async fn try_decrypt(
|
|||||||
// Apply Autocrypt header
|
// Apply Autocrypt header
|
||||||
if let Some(ref header) = Aheader::from_headers(context, &from, &mail.headers) {
|
if let Some(ref header) = Aheader::from_headers(context, &from, &mail.headers) {
|
||||||
if let Some(ref mut peerstate) = peerstate {
|
if let Some(ref mut peerstate) = peerstate {
|
||||||
peerstate.apply_header(&header, message_time);
|
peerstate.apply_header(header, message_time);
|
||||||
peerstate.save_to_db(&context.sql, false).await?;
|
peerstate.save_to_db(&context.sql, false).await?;
|
||||||
} else {
|
} else {
|
||||||
let p = Peerstate::from_header(context, header, message_time);
|
let p = Peerstate::from_header(context, header, message_time);
|
||||||
@@ -504,7 +504,7 @@ Sent with my Delta Chat Messenger: https://delta.chat";
|
|||||||
let addr = "bob@foo.bar";
|
let addr = "bob@foo.bar";
|
||||||
let pub_key = bob_keypair().public;
|
let pub_key = bob_keypair().public;
|
||||||
let peerstate = Peerstate {
|
let peerstate = Peerstate {
|
||||||
context: &ctx,
|
context: ctx,
|
||||||
addr: addr.into(),
|
addr: addr.into(),
|
||||||
last_seen: 13,
|
last_seen: 13,
|
||||||
last_seen_autocrypt: 14,
|
last_seen_autocrypt: 14,
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn check_msg_was_deleted(t: &TestContext, chat: &Chat, msg_id: MsgId) {
|
async fn check_msg_was_deleted(t: &TestContext, chat: &Chat, msg_id: MsgId) {
|
||||||
let chat_items = chat::get_chat_msgs(&t, chat.id, 0, None).await;
|
let chat_items = chat::get_chat_msgs(t, chat.id, 0, None).await;
|
||||||
// Check that the chat is empty except for possibly info messages:
|
// Check that the chat is empty except for possibly info messages:
|
||||||
for item in &chat_items {
|
for item in &chat_items {
|
||||||
if let ChatItem::Message { msg_id } = item {
|
if let ChatItem::Message { msg_id } = item {
|
||||||
@@ -725,13 +725,13 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that if there is a message left, the text and metadata are gone
|
// Check that if there is a message left, the text and metadata are gone
|
||||||
if let Ok(msg) = Message::load_from_db(&t, msg_id).await {
|
if let Ok(msg) = Message::load_from_db(t, msg_id).await {
|
||||||
assert_eq!(msg.from_id, 0);
|
assert_eq!(msg.from_id, 0);
|
||||||
assert_eq!(msg.to_id, 0);
|
assert_eq!(msg.to_id, 0);
|
||||||
assert!(msg.text.is_none_or_empty(), msg.text);
|
assert!(msg.text.is_none_or_empty(), msg.text);
|
||||||
let rawtxt: Option<String> = t
|
let rawtxt: Option<String> = t
|
||||||
.sql
|
.sql
|
||||||
.query_get_value(&t, "SELECT txt_raw FROM msgs WHERE id=?;", paramsv![msg_id])
|
.query_get_value(t, "SELECT txt_raw FROM msgs WHERE id=?;", paramsv![msg_id])
|
||||||
.await;
|
.await;
|
||||||
assert!(rawtxt.is_none_or_empty(), rawtxt);
|
assert!(rawtxt.is_none_or_empty(), rawtxt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ impl HtmlMsgParser {
|
|||||||
if mimetype.type_() == mime::IMAGE {
|
if mimetype.type_() == mime::IMAGE {
|
||||||
if let Some(cid) = mail.headers.get_header_value(HeaderDef::ContentId) {
|
if let Some(cid) = mail.headers.get_header_value(HeaderDef::ContentId) {
|
||||||
if let Ok(cid) = parse_message_id(&cid) {
|
if let Ok(cid) = parse_message_id(&cid) {
|
||||||
if let Ok(replacement) = mimepart_to_data_url(&mail).await {
|
if let Ok(replacement) = mimepart_to_data_url(mail).await {
|
||||||
let re_string = format!(
|
let re_string = format!(
|
||||||
"(<img[^>]*src[^>]*=[^>]*)(cid:{})([^>]*>)",
|
"(<img[^>]*src[^>]*=[^>]*)(cid:{})([^>]*>)",
|
||||||
regex::escape(&cid)
|
regex::escape(&cid)
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ impl Imap {
|
|||||||
let new_uid_next = largest_uid_without_errors + 1;
|
let new_uid_next = largest_uid_without_errors + 1;
|
||||||
|
|
||||||
if new_uid_next > old_uid_next {
|
if new_uid_next > old_uid_next {
|
||||||
set_uid_next(context, &folder, new_uid_next).await?;
|
set_uid_next(context, folder, new_uid_next).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if read_errors == 0 {
|
if read_errors == 0 {
|
||||||
@@ -932,7 +932,7 @@ impl Imap {
|
|||||||
|
|
||||||
match dc_receive_imf_inner(
|
match dc_receive_imf_inner(
|
||||||
&context,
|
&context,
|
||||||
&body,
|
body,
|
||||||
&folder,
|
&folder,
|
||||||
server_uid,
|
server_uid,
|
||||||
is_seen,
|
is_seen,
|
||||||
@@ -1311,7 +1311,7 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let folder_meaning = get_folder_meaning(&folder);
|
let folder_meaning = get_folder_meaning(&folder);
|
||||||
let folder_name_meaning = get_folder_meaning_by_name(&folder.name());
|
let folder_name_meaning = get_folder_meaning_by_name(folder.name());
|
||||||
if folder.name() == "DeltaChat" {
|
if folder.name() == "DeltaChat" {
|
||||||
// Always takes precendent
|
// Always takes precendent
|
||||||
mvbox_folder = Some(folder.name().to_string());
|
mvbox_folder = Some(folder.name().to_string());
|
||||||
@@ -1501,7 +1501,7 @@ async fn precheck_imf(
|
|||||||
server_uid: u32,
|
server_uid: u32,
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
if let Some((old_server_folder, old_server_uid, msg_id)) =
|
if let Some((old_server_folder, old_server_uid, msg_id)) =
|
||||||
message::rfc724_mid_exists(context, &rfc724_mid).await?
|
message::rfc724_mid_exists(context, rfc724_mid).await?
|
||||||
{
|
{
|
||||||
if old_server_folder.is_empty() && old_server_uid == 0 {
|
if old_server_folder.is_empty() && old_server_uid == 0 {
|
||||||
info!(
|
info!(
|
||||||
@@ -1667,7 +1667,7 @@ async fn message_needs_processing(
|
|||||||
folder: &str,
|
folder: &str,
|
||||||
show_emails: ShowEmails,
|
show_emails: ShowEmails,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let skip = match precheck_imf(context, &msg_id, folder, current_uid).await {
|
let skip = match precheck_imf(context, msg_id, folder, current_uid).await {
|
||||||
Ok(skip) => skip,
|
Ok(skip) => skip,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(context, "precheck_imf error: {}", err);
|
warn!(context, "precheck_imf error: {}", err);
|
||||||
@@ -1687,7 +1687,7 @@ async fn message_needs_processing(
|
|||||||
// we do not know the message-id
|
// we do not know the message-id
|
||||||
// or the message-id is missing (in this case, we create one in the further process)
|
// or the message-id is missing (in this case, we create one in the further process)
|
||||||
// or some other error happened
|
// or some other error happened
|
||||||
let show = match prefetch_should_download(context, &headers, show_emails).await {
|
let show = match prefetch_should_download(context, headers, show_emails).await {
|
||||||
Ok(show) => show,
|
Ok(show) => show,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(context, "prefetch_should_download error: {}", err);
|
warn!(context, "prefetch_should_download error: {}", err);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ impl Imap {
|
|||||||
info!(context, "Scanning folder: {}", foldername);
|
info!(context, "Scanning folder: {}", foldername);
|
||||||
|
|
||||||
let folder_meaning = get_folder_meaning(&folder);
|
let folder_meaning = get_folder_meaning(&folder);
|
||||||
let folder_name_meaning = get_folder_meaning_by_name(&foldername);
|
let folder_name_meaning = get_folder_meaning_by_name(foldername);
|
||||||
|
|
||||||
if folder_meaning == FolderMeaning::SentObjects {
|
if folder_meaning == FolderMeaning::SentObjects {
|
||||||
// Always takes precedent
|
// Always takes precedent
|
||||||
|
|||||||
12
src/imex.rs
12
src/imex.rs
@@ -263,7 +263,7 @@ pub async fn render_setup_file(context: &Context, passphrase: &str) -> Result<St
|
|||||||
true => Some(("Autocrypt-Prefer-Encrypt", "mutual")),
|
true => Some(("Autocrypt-Prefer-Encrypt", "mutual")),
|
||||||
};
|
};
|
||||||
let private_key_asc = private_key.to_asc(ac_headers);
|
let private_key_asc = private_key.to_asc(ac_headers);
|
||||||
let encr = pgp::symm_encrypt(&passphrase, private_key_asc.as_bytes()).await?;
|
let encr = pgp::symm_encrypt(passphrase, private_key_asc.as_bytes()).await?;
|
||||||
|
|
||||||
let replacement = format!(
|
let replacement = format!(
|
||||||
concat!(
|
concat!(
|
||||||
@@ -529,11 +529,11 @@ async fn import_backup(context: &Context, backup_to_import: impl AsRef<Path>) ->
|
|||||||
|
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.open(&context, &context.get_dbfile(), false)
|
.open(context, &context.get_dbfile(), false)
|
||||||
.await
|
.await
|
||||||
.context("Could not re-open db")?;
|
.context("Could not re-open db")?;
|
||||||
|
|
||||||
delete_and_reset_all_device_msgs(&context).await?;
|
delete_and_reset_all_device_msgs(context).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -565,11 +565,11 @@ async fn import_backup_old(context: &Context, backup_to_import: impl AsRef<Path>
|
|||||||
/* re-open copied database file */
|
/* re-open copied database file */
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.open(&context, &context.get_dbfile(), false)
|
.open(context, &context.get_dbfile(), false)
|
||||||
.await
|
.await
|
||||||
.context("Could not re-open db")?;
|
.context("Could not re-open db")?;
|
||||||
|
|
||||||
delete_and_reset_all_device_msgs(&context).await?;
|
delete_and_reset_all_device_msgs(context).await?;
|
||||||
|
|
||||||
let total_files_cnt = context
|
let total_files_cnt = context
|
||||||
.sql
|
.sql
|
||||||
@@ -678,7 +678,7 @@ async fn export_backup(context: &Context, dir: impl AsRef<Path>) -> Result<()> {
|
|||||||
// we re-open the database after export is finished
|
// we re-open the database after export is finished
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.open(&context, &context.get_dbfile(), false)
|
.open(context, &context.get_dbfile(), false)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match &res {
|
match &res {
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
clippy::all,
|
clippy::all,
|
||||||
clippy::indexing_slicing,
|
clippy::indexing_slicing,
|
||||||
clippy::wildcard_imports
|
clippy::wildcard_imports,
|
||||||
|
clippy::needless_borrow
|
||||||
)]
|
)]
|
||||||
#![allow(clippy::match_bool, clippy::eval_order_dependence)]
|
#![allow(clippy::match_bool, clippy::eval_order_dependence)]
|
||||||
|
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ impl Message {
|
|||||||
|
|
||||||
// add/replace room
|
// add/replace room
|
||||||
let url = if url.contains("$ROOM") {
|
let url = if url.contains("$ROOM") {
|
||||||
url.replace("$ROOM", &room)
|
url.replace("$ROOM", room)
|
||||||
} else if url.contains("$NOROOM") {
|
} else if url.contains("$NOROOM") {
|
||||||
// there are some usecases where a separate room is not needed to use a service
|
// there are some usecases where a separate room is not needed to use a service
|
||||||
// eg. if you let in people manually anyway, see discussion at
|
// eg. if you let in people manually anyway, see discussion at
|
||||||
@@ -2286,66 +2286,65 @@ mod tests {
|
|||||||
some_file.set(Param::File, "foo.bar");
|
some_file.set(Param::File, "foo.bar");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Text, some_text.as_ref(), &Params::new(), 50, &ctx)
|
get_summarytext_by_raw(Viewtype::Text, some_text.as_ref(), &Params::new(), 50, ctx)
|
||||||
.await,
|
.await,
|
||||||
"bla bla" // for simple text, the type is not added to the summary
|
"bla bla" // for simple text, the type is not added to the summary
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Image, no_text.as_ref(), &some_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::Image, no_text.as_ref(), &some_file, 50, ctx).await,
|
||||||
"Image" // file names are not added for images
|
"Image" // file names are not added for images
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Video, no_text.as_ref(), &some_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::Video, no_text.as_ref(), &some_file, 50, ctx).await,
|
||||||
"Video" // file names are not added for videos
|
"Video" // file names are not added for videos
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Gif, no_text.as_ref(), &some_file, 50, &ctx,).await,
|
get_summarytext_by_raw(Viewtype::Gif, no_text.as_ref(), &some_file, 50, ctx,).await,
|
||||||
"GIF" // file names are not added for GIFs
|
"GIF" // file names are not added for GIFs
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Sticker, no_text.as_ref(), &some_file, 50, &ctx,)
|
get_summarytext_by_raw(Viewtype::Sticker, no_text.as_ref(), &some_file, 50, ctx,).await,
|
||||||
.await,
|
|
||||||
"Sticker" // file names are not added for stickers
|
"Sticker" // file names are not added for stickers
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Voice, empty_text.as_ref(), &some_file, 50, &ctx,)
|
get_summarytext_by_raw(Viewtype::Voice, empty_text.as_ref(), &some_file, 50, ctx,)
|
||||||
.await,
|
.await,
|
||||||
"Voice message" // file names are not added for voice messages, empty text is skipped
|
"Voice message" // file names are not added for voice messages, empty text is skipped
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Voice, no_text.as_ref(), &some_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::Voice, no_text.as_ref(), &some_file, 50, ctx).await,
|
||||||
"Voice message" // file names are not added for voice messages
|
"Voice message" // file names are not added for voice messages
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Voice, some_text.as_ref(), &some_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::Voice, some_text.as_ref(), &some_file, 50, ctx).await,
|
||||||
"Voice message \u{2013} bla bla" // `\u{2013}` explicitly checks for "EN DASH"
|
"Voice message \u{2013} bla bla" // `\u{2013}` explicitly checks for "EN DASH"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Audio, no_text.as_ref(), &some_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::Audio, no_text.as_ref(), &some_file, 50, ctx).await,
|
||||||
"Audio \u{2013} foo.bar" // file name is added for audio
|
"Audio \u{2013} foo.bar" // file name is added for audio
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Audio, empty_text.as_ref(), &some_file, 50, &ctx,)
|
get_summarytext_by_raw(Viewtype::Audio, empty_text.as_ref(), &some_file, 50, ctx,)
|
||||||
.await,
|
.await,
|
||||||
"Audio \u{2013} foo.bar" // file name is added for audio, empty text is not added
|
"Audio \u{2013} foo.bar" // file name is added for audio, empty text is not added
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::Audio, some_text.as_ref(), &some_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::Audio, some_text.as_ref(), &some_file, 50, ctx).await,
|
||||||
"Audio \u{2013} foo.bar \u{2013} bla bla" // file name and text added for audio
|
"Audio \u{2013} foo.bar \u{2013} bla bla" // file name and text added for audio
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::File, some_text.as_ref(), &some_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::File, some_text.as_ref(), &some_file, 50, ctx).await,
|
||||||
"File \u{2013} foo.bar \u{2013} bla bla" // file name is added for files
|
"File \u{2013} foo.bar \u{2013} bla bla" // file name is added for files
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2353,7 +2352,7 @@ mod tests {
|
|||||||
asm_file.set(Param::File, "foo.bar");
|
asm_file.set(Param::File, "foo.bar");
|
||||||
asm_file.set_cmd(SystemMessage::AutocryptSetupMessage);
|
asm_file.set_cmd(SystemMessage::AutocryptSetupMessage);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_summarytext_by_raw(Viewtype::File, no_text.as_ref(), &asm_file, 50, &ctx).await,
|
get_summarytext_by_raw(Viewtype::File, no_text.as_ref(), &asm_file, 50, ctx).await,
|
||||||
"Autocrypt Setup Message" // file name is not added for autocrypt setup messages
|
"Autocrypt Setup Message" // file name is not added for autocrypt setup messages
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -959,13 +959,13 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
|||||||
|
|
||||||
// add attachment part
|
// add attachment part
|
||||||
if chat::msgtype_has_file(self.msg.viewtype) {
|
if chat::msgtype_has_file(self.msg.viewtype) {
|
||||||
if !is_file_size_okay(context, &self.msg).await {
|
if !is_file_size_okay(context, self.msg).await {
|
||||||
bail!(
|
bail!(
|
||||||
"Message exceeds the recommended {} MB.",
|
"Message exceeds the recommended {} MB.",
|
||||||
RECOMMENDED_FILE_SIZE / 1_000_000,
|
RECOMMENDED_FILE_SIZE / 1_000_000,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let (file_part, _) = build_body_file(context, &self.msg, "").await?;
|
let (file_part, _) = build_body_file(context, self.msg, "").await?;
|
||||||
parts.push(file_part);
|
parts.push(file_part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1078,7 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
|||||||
"Additional-Message-IDs: ".to_string()
|
"Additional-Message-IDs: ".to_string()
|
||||||
+ &additional_msg_ids
|
+ &additional_msg_ids
|
||||||
.iter()
|
.iter()
|
||||||
.map(|mid| render_rfc724_mid(&mid))
|
.map(|mid| render_rfc724_mid(mid))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join(" ")
|
.join(" ")
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ impl MimeMessage {
|
|||||||
// See if an MDN is requested from the other side
|
// See if an MDN is requested from the other side
|
||||||
if !self.decrypting_failed && !self.parts.is_empty() {
|
if !self.decrypting_failed && !self.parts.is_empty() {
|
||||||
if let Some(ref dn_to) = self.chat_disposition_notification_to {
|
if let Some(ref dn_to) = self.chat_disposition_notification_to {
|
||||||
if let Some(ref from) = self.from.get(0) {
|
if let Some(from) = self.from.get(0) {
|
||||||
if from.addr.to_lowercase() == dn_to.addr.to_lowercase() {
|
if from.addr.to_lowercase() == dn_to.addr.to_lowercase() {
|
||||||
if let Some(part) = self.parts.last_mut() {
|
if let Some(part) = self.parts.last_mut() {
|
||||||
part.param.set_int(Param::WantsMdn, 1);
|
part.param.set_int(Param::WantsMdn, 1);
|
||||||
@@ -1355,7 +1355,7 @@ fn get_attachment_filename(
|
|||||||
let mut parts = name.splitn(3, '\'');
|
let mut parts = name.splitn(3, '\'');
|
||||||
desired_filename =
|
desired_filename =
|
||||||
if let (Some(charset), Some(value)) = (parts.next(), parts.last()) {
|
if let (Some(charset), Some(value)) = (parts.next(), parts.last()) {
|
||||||
let decoded_bytes = percent_decode_str(&value);
|
let decoded_bytes = percent_decode_str(value);
|
||||||
if charset.to_lowercase() == "utf-8" {
|
if charset.to_lowercase() == "utf-8" {
|
||||||
Some(decoded_bytes.decode_utf8_lossy().to_string())
|
Some(decoded_bytes.decode_utf8_lossy().to_string())
|
||||||
} else {
|
} else {
|
||||||
@@ -1597,8 +1597,8 @@ mod tests {
|
|||||||
|
|
||||||
fn load_mail_with_attachment<'a>(t: &'a TestContext, raw: &'a [u8]) -> ParsedMail<'a> {
|
fn load_mail_with_attachment<'a>(t: &'a TestContext, raw: &'a [u8]) -> ParsedMail<'a> {
|
||||||
let mail = mailparse::parse_mail(raw).unwrap();
|
let mail = mailparse::parse_mail(raw).unwrap();
|
||||||
assert!(get_attachment_filename(&t, &mail).unwrap().is_none());
|
assert!(get_attachment_filename(t, &mail).unwrap().is_none());
|
||||||
assert!(get_attachment_filename(&t, &mail.subparts[0])
|
assert!(get_attachment_filename(t, &mail.subparts[0])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_none());
|
.is_none());
|
||||||
mail
|
mail
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ impl Oauth2 {
|
|||||||
.find('@')
|
.find('@')
|
||||||
.map(|index| addr_normalized.split_at(index + 1).1)
|
.map(|index| addr_normalized.split_at(index + 1).1)
|
||||||
{
|
{
|
||||||
if let Some(oauth2_authorizer) = provider::get_provider_info(&domain)
|
if let Some(oauth2_authorizer) = provider::get_provider_info(domain)
|
||||||
.await
|
.await
|
||||||
.and_then(|provider| provider.oauth2_authorizer.as_ref())
|
.and_then(|provider| provider.oauth2_authorizer.as_ref())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ pub async fn get_provider_by_mx(domain: impl AsRef<str>) -> Option<&'static Prov
|
|||||||
|
|
||||||
pub fn get_provider_by_id(id: &str) -> Option<&'static Provider> {
|
pub fn get_provider_by_id(id: &str) -> Option<&'static Provider> {
|
||||||
if let Some(provider) = PROVIDER_IDS.get(id) {
|
if let Some(provider) = PROVIDER_IDS.get(id) {
|
||||||
Some(&provider)
|
Some(provider)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ fn normalize_address(addr: &str) -> Result<String, Error> {
|
|||||||
let new_addr = percent_decode_str(addr).decode_utf8()?;
|
let new_addr = percent_decode_str(addr).decode_utf8()?;
|
||||||
let new_addr = addr_normalize(&new_addr);
|
let new_addr = addr_normalize(&new_addr);
|
||||||
|
|
||||||
ensure!(may_be_valid_addr(&new_addr), "Bad e-mail address");
|
ensure!(may_be_valid_addr(new_addr), "Bad e-mail address");
|
||||||
|
|
||||||
Ok(new_addr.to_string())
|
Ok(new_addr.to_string())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,20 +119,20 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne
|
|||||||
async fn fetch(ctx: &Context, connection: &mut Imap) {
|
async fn fetch(ctx: &Context, connection: &mut Imap) {
|
||||||
match ctx.get_config(Config::ConfiguredInboxFolder).await {
|
match ctx.get_config(Config::ConfiguredInboxFolder).await {
|
||||||
Some(watch_folder) => {
|
Some(watch_folder) => {
|
||||||
if let Err(err) = connection.connect_configured(&ctx).await {
|
if let Err(err) = connection.connect_configured(ctx).await {
|
||||||
error_network!(ctx, "{}", err);
|
error_network!(ctx, "{}", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch
|
// fetch
|
||||||
if let Err(err) = connection.fetch(&ctx, &watch_folder).await {
|
if let Err(err) = connection.fetch(ctx, &watch_folder).await {
|
||||||
connection.trigger_reconnect();
|
connection.trigger_reconnect();
|
||||||
warn!(ctx, "{:#}", err);
|
warn!(ctx, "{:#}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
warn!(ctx, "Can not fetch inbox folder, not set");
|
warn!(ctx, "Can not fetch inbox folder, not set");
|
||||||
connection.fake_idle(&ctx, None).await;
|
connection.fake_idle(ctx, None).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,18 +141,18 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder: Config) -> Int
|
|||||||
match ctx.get_config(folder).await {
|
match ctx.get_config(folder).await {
|
||||||
Some(watch_folder) => {
|
Some(watch_folder) => {
|
||||||
// connect and fake idle if unable to connect
|
// connect and fake idle if unable to connect
|
||||||
if let Err(err) = connection.connect_configured(&ctx).await {
|
if let Err(err) = connection.connect_configured(ctx).await {
|
||||||
warn!(ctx, "imap connection failed: {}", err);
|
warn!(ctx, "imap connection failed: {}", err);
|
||||||
return connection.fake_idle(&ctx, Some(watch_folder)).await;
|
return connection.fake_idle(ctx, Some(watch_folder)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch
|
// fetch
|
||||||
if let Err(err) = connection.fetch(&ctx, &watch_folder).await {
|
if let Err(err) = connection.fetch(ctx, &watch_folder).await {
|
||||||
connection.trigger_reconnect();
|
connection.trigger_reconnect();
|
||||||
warn!(ctx, "{:#}", err);
|
warn!(ctx, "{:#}", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = connection.scan_folders(&ctx).await {
|
if let Err(err) = connection.scan_folders(ctx).await {
|
||||||
// Don't reconnect, if there is a problem with the connection we will realize this when IDLEing
|
// Don't reconnect, if there is a problem with the connection we will realize this when IDLEing
|
||||||
// but maybe just one folder can't be selected or something
|
// but maybe just one folder can't be selected or something
|
||||||
warn!(ctx, "{}", err);
|
warn!(ctx, "{}", err);
|
||||||
@@ -161,7 +161,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder: Config) -> Int
|
|||||||
// idle
|
// idle
|
||||||
if connection.can_idle() {
|
if connection.can_idle() {
|
||||||
connection
|
connection
|
||||||
.idle(&ctx, Some(watch_folder))
|
.idle(ctx, Some(watch_folder))
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
connection.trigger_reconnect();
|
connection.trigger_reconnect();
|
||||||
@@ -169,12 +169,12 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder: Config) -> Int
|
|||||||
InterruptInfo::new(false, None)
|
InterruptInfo::new(false, None)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
connection.fake_idle(&ctx, Some(watch_folder)).await
|
connection.fake_idle(ctx, Some(watch_folder)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
warn!(ctx, "Can not watch {} folder, not set", folder);
|
warn!(ctx, "Can not watch {} folder, not set", folder);
|
||||||
connection.fake_idle(&ctx, None).await
|
connection.fake_idle(ctx, None).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ pub async fn dc_get_securejoin_qr(context: &Context, group: Option<ChatId>) -> O
|
|||||||
if let Ok(chat) = Chat::load_from_db(context, group).await {
|
if let Ok(chat) = Chat::load_from_db(context, group).await {
|
||||||
let group_name = chat.get_name();
|
let group_name = chat.get_name();
|
||||||
let group_name_urlencoded =
|
let group_name_urlencoded =
|
||||||
utf8_percent_encode(&group_name, NON_ALPHANUMERIC).to_string();
|
utf8_percent_encode(group_name, NON_ALPHANUMERIC).to_string();
|
||||||
|
|
||||||
Some(format!(
|
Some(format!(
|
||||||
"OPENPGP4FPR:{}#a={}&g={}&x={}&i={}&s={}",
|
"OPENPGP4FPR:{}#a={}&g={}&x={}&i={}&s={}",
|
||||||
@@ -489,7 +489,7 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
return Ok(HandshakeMessage::Ignore);
|
return Ok(HandshakeMessage::Ignore);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if !token::exists(context, token::Namespace::InviteNumber, &invitenumber).await {
|
if !token::exists(context, token::Namespace::InviteNumber, invitenumber).await {
|
||||||
warn!(context, "Secure-join denied (bad invitenumber).");
|
warn!(context, "Secure-join denied (bad invitenumber).");
|
||||||
return Ok(HandshakeMessage::Ignore);
|
return Ok(HandshakeMessage::Ignore);
|
||||||
}
|
}
|
||||||
@@ -583,7 +583,7 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
return Ok(HandshakeMessage::Ignore);
|
return Ok(HandshakeMessage::Ignore);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if !token::exists(context, token::Namespace::Auth, &auth_0).await {
|
if !token::exists(context, token::Namespace::Auth, auth_0).await {
|
||||||
could_not_establish_secure_connection(context, contact_chat_id, "Auth invalid.")
|
could_not_establish_secure_connection(context, contact_chat_id, "Auth invalid.")
|
||||||
.await;
|
.await;
|
||||||
return Ok(HandshakeMessage::Ignore);
|
return Ok(HandshakeMessage::Ignore);
|
||||||
|
|||||||
@@ -47,21 +47,21 @@ impl QrInvite {
|
|||||||
/// The fingerprint of the inviter.
|
/// The fingerprint of the inviter.
|
||||||
pub fn fingerprint(&self) -> &Fingerprint {
|
pub fn fingerprint(&self) -> &Fingerprint {
|
||||||
match self {
|
match self {
|
||||||
Self::Contact { fingerprint, .. } | Self::Group { fingerprint, .. } => &fingerprint,
|
Self::Contact { fingerprint, .. } | Self::Group { fingerprint, .. } => fingerprint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `INVITENUMBER` of the setup-contact/secure-join protocol.
|
/// The `INVITENUMBER` of the setup-contact/secure-join protocol.
|
||||||
pub fn invitenumber(&self) -> &str {
|
pub fn invitenumber(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Self::Contact { invitenumber, .. } | Self::Group { invitenumber, .. } => &invitenumber,
|
Self::Contact { invitenumber, .. } | Self::Group { invitenumber, .. } => invitenumber,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `AUTH` code of the setup-contact/secure-join protocol.
|
/// The `AUTH` code of the setup-contact/secure-join protocol.
|
||||||
pub fn authcode(&self) -> &str {
|
pub fn authcode(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Self::Contact { authcode, .. } | Self::Group { authcode, .. } => &authcode,
|
Self::Contact { authcode, .. } | Self::Group { authcode, .. } => authcode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ impl Sql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let key = key.as_ref();
|
let key = key.as_ref();
|
||||||
let res = if let Some(ref value) = value {
|
let res = if let Some(value) = value {
|
||||||
let exists = self
|
let exists = self
|
||||||
.exists("SELECT value FROM config WHERE keyname=?;", paramsv![key])
|
.exists("SELECT value FROM config WHERE keyname=?;", paramsv![key])
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -904,28 +904,28 @@ impl Context {
|
|||||||
|
|
||||||
// create saved-messages chat; we do this only once, if the user has deleted the chat,
|
// create saved-messages chat; we do this only once, if the user has deleted the chat,
|
||||||
// he can recreate it manually (make sure we do not re-add it when configure() was called a second time)
|
// he can recreate it manually (make sure we do not re-add it when configure() was called a second time)
|
||||||
if !self.sql.get_raw_config_bool(&self, "self-chat-added").await {
|
if !self.sql.get_raw_config_bool(self, "self-chat-added").await {
|
||||||
self.sql
|
self.sql
|
||||||
.set_raw_config_bool(&self, "self-chat-added", true)
|
.set_raw_config_bool(self, "self-chat-added", true)
|
||||||
.await?;
|
.await?;
|
||||||
chat::create_by_contact_id(&self, DC_CONTACT_ID_SELF).await?;
|
chat::create_by_contact_id(self, DC_CONTACT_ID_SELF).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add welcome-messages. by the label, this is done only once,
|
// add welcome-messages. by the label, this is done only once,
|
||||||
// if the user has deleted the message or the chat, it is not added again.
|
// if the user has deleted the message or the chat, it is not added again.
|
||||||
let mut msg = Message::new(Viewtype::Text);
|
let mut msg = Message::new(Viewtype::Text);
|
||||||
msg.text = Some(device_messages_hint(self).await);
|
msg.text = Some(device_messages_hint(self).await);
|
||||||
chat::add_device_msg(&self, Some("core-about-device-chat"), Some(&mut msg)).await?;
|
chat::add_device_msg(self, Some("core-about-device-chat"), Some(&mut msg)).await?;
|
||||||
|
|
||||||
let image = include_bytes!("../assets/welcome-image.jpg");
|
let image = include_bytes!("../assets/welcome-image.jpg");
|
||||||
let blob = BlobObject::create(&self, "welcome-image.jpg".to_string(), image).await?;
|
let blob = BlobObject::create(self, "welcome-image.jpg".to_string(), image).await?;
|
||||||
let mut msg = Message::new(Viewtype::Image);
|
let mut msg = Message::new(Viewtype::Image);
|
||||||
msg.param.set(Param::File, blob.as_name());
|
msg.param.set(Param::File, blob.as_name());
|
||||||
chat::add_device_msg(&self, Some("core-welcome-image"), Some(&mut msg)).await?;
|
chat::add_device_msg(self, Some("core-welcome-image"), Some(&mut msg)).await?;
|
||||||
|
|
||||||
let mut msg = Message::new(Viewtype::Text);
|
let mut msg = Message::new(Viewtype::Text);
|
||||||
msg.text = Some(welcome_message(self).await);
|
msg.text = Some(welcome_message(self).await);
|
||||||
chat::add_device_msg(&self, Some("core-welcome"), Some(&mut msg)).await?;
|
chat::add_device_msg(self, Some("core-welcome"), Some(&mut msg)).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -353,8 +353,8 @@ impl TestContext {
|
|||||||
pub async fn send_text(&self, chat_id: ChatId, txt: &str) -> SentMessage {
|
pub async fn send_text(&self, chat_id: ChatId, txt: &str) -> SentMessage {
|
||||||
let mut msg = Message::new(Viewtype::Text);
|
let mut msg = Message::new(Viewtype::Text);
|
||||||
msg.set_text(Some(txt.to_string()));
|
msg.set_text(Some(txt.to_string()));
|
||||||
chat::prepare_msg(&self, chat_id, &mut msg).await.unwrap();
|
chat::prepare_msg(self, chat_id, &mut msg).await.unwrap();
|
||||||
chat::send_msg(&self, chat_id, &mut msg).await.unwrap();
|
chat::send_msg(self, chat_id, &mut msg).await.unwrap();
|
||||||
self.pop_sent_msg().await
|
self.pop_sent_msg().await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ impl TestContext {
|
|||||||
// merge them to a public function in the `deltachat` crate.
|
// merge them to a public function in the `deltachat` crate.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn print_chat(&self, chat: &Chat) {
|
pub async fn print_chat(&self, chat: &Chat) {
|
||||||
let msglist = chat::get_chat_msgs(&self, chat.get_id(), 0x1, None).await;
|
let msglist = chat::get_chat_msgs(self, chat.get_id(), 0x1, None).await;
|
||||||
let msglist: Vec<MsgId> = msglist
|
let msglist: Vec<MsgId> = msglist
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| match x {
|
.map(|x| match x {
|
||||||
@@ -390,7 +390,7 @@ impl TestContext {
|
|||||||
);
|
);
|
||||||
lines_out += 1
|
lines_out += 1
|
||||||
}
|
}
|
||||||
let msg = Message::load_from_db(&self, msg_id).await.unwrap();
|
let msg = Message::load_from_db(self, msg_id).await.unwrap();
|
||||||
log_msg(self, "", &msg).await;
|
log_msg(self, "", &msg).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -559,7 +559,7 @@ fn receive_event(event: Event) {
|
|||||||
};
|
};
|
||||||
let context_names = CONTEXT_NAMES.read().unwrap();
|
let context_names = CONTEXT_NAMES.read().unwrap();
|
||||||
match context_names.get(&event.id) {
|
match context_names.get(&event.id) {
|
||||||
Some(ref name) => println!("{} {}", name, msg),
|
Some(name) => println!("{} {}", name, msg),
|
||||||
None => println!("{} {}", event.id, msg),
|
None => println!("{} {}", event.id, msg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user