mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Merge branch 'stable'
This commit is contained in:
@@ -34,7 +34,7 @@ pub struct MessageObject {
|
|||||||
quote: Option<MessageQuote>,
|
quote: Option<MessageQuote>,
|
||||||
parent_id: Option<u32>,
|
parent_id: Option<u32>,
|
||||||
|
|
||||||
text: Option<String>,
|
text: String,
|
||||||
has_location: bool,
|
has_location: bool,
|
||||||
has_html: bool,
|
has_html: bool,
|
||||||
view_type: MessageViewtype,
|
view_type: MessageViewtype,
|
||||||
@@ -180,7 +180,7 @@ impl MessageObject {
|
|||||||
from_id: message.get_from_id().to_u32(),
|
from_id: message.get_from_id().to_u32(),
|
||||||
quote,
|
quote,
|
||||||
parent_id,
|
parent_id,
|
||||||
text: Some(message.get_text()).filter(|s| !s.is_empty()),
|
text: message.get_text(),
|
||||||
has_location: message.has_location(),
|
has_location: message.has_location(),
|
||||||
has_html: message.has_html(),
|
has_html: message.has_html(),
|
||||||
view_type: message.get_viewtype().into(),
|
view_type: message.get_viewtype().into(),
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class EventType(str, Enum):
|
|||||||
MSG_DELIVERED = "MsgDelivered"
|
MSG_DELIVERED = "MsgDelivered"
|
||||||
MSG_FAILED = "MsgFailed"
|
MSG_FAILED = "MsgFailed"
|
||||||
MSG_READ = "MsgRead"
|
MSG_READ = "MsgRead"
|
||||||
|
MSG_DELETED = "MsgDeleted"
|
||||||
CHAT_MODIFIED = "ChatModified"
|
CHAT_MODIFIED = "ChatModified"
|
||||||
CHAT_EPHEMERAL_TIMER_MODIFIED = "ChatEphemeralTimerModified"
|
CHAT_EPHEMERAL_TIMER_MODIFIED = "ChatEphemeralTimerModified"
|
||||||
CONTACTS_CHANGED = "ContactsChanged"
|
CONTACTS_CHANGED = "ContactsChanged"
|
||||||
|
|||||||
@@ -101,6 +101,16 @@ async def test_account(acfactory) -> None:
|
|||||||
assert await alice.get_fresh_messages()
|
assert await alice.get_fresh_messages()
|
||||||
assert await alice.get_next_messages()
|
assert await alice.get_next_messages()
|
||||||
|
|
||||||
|
# Test sending empty message.
|
||||||
|
assert len(await bob.wait_next_messages()) == 0
|
||||||
|
await alice_chat_bob.send_text("")
|
||||||
|
messages = await bob.wait_next_messages()
|
||||||
|
assert len(messages) == 1
|
||||||
|
message = messages[0]
|
||||||
|
snapshot = await message.get_snapshot()
|
||||||
|
assert snapshot.text == ""
|
||||||
|
await bob.mark_seen_messages([message])
|
||||||
|
|
||||||
group = await alice.create_group("test group")
|
group = await alice.create_group("test group")
|
||||||
await group.add_contact(alice_contact_bob)
|
await group.add_contact(alice_contact_bob)
|
||||||
group_msg = await group.send_message(text="hello")
|
group_msg = await group.send_message(text="hello")
|
||||||
|
|||||||
19
src/imap.rs
19
src/imap.rs
@@ -611,8 +611,7 @@ impl Imap {
|
|||||||
if uid_next < old_uid_next {
|
if uid_next < old_uid_next {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"The server illegally decreased the uid_next of folder {} from {} to {} without changing validity ({}), resyncing UIDs...",
|
"The server illegally decreased the uid_next of folder {folder:?} from {old_uid_next} to {uid_next} without changing validity ({new_uid_validity}), resyncing UIDs...",
|
||||||
folder, old_uid_next, uid_next, new_uid_validity,
|
|
||||||
);
|
);
|
||||||
set_uid_next(context, folder, uid_next).await?;
|
set_uid_next(context, folder, uid_next).await?;
|
||||||
job::schedule_resync(context).await?;
|
job::schedule_resync(context).await?;
|
||||||
@@ -628,7 +627,7 @@ impl Imap {
|
|||||||
set_modseq(context, folder, 0).await?;
|
set_modseq(context, folder, 0).await?;
|
||||||
|
|
||||||
if mailbox.exists == 0 {
|
if mailbox.exists == 0 {
|
||||||
info!(context, "Folder \"{}\" is empty.", folder);
|
info!(context, "Folder {folder:?} is empty.");
|
||||||
|
|
||||||
// set uid_next=1 for empty folders.
|
// set uid_next=1 for empty folders.
|
||||||
// If we do not do this here, we'll miss the first message
|
// If we do not do this here, we'll miss the first message
|
||||||
@@ -646,7 +645,7 @@ impl Imap {
|
|||||||
None => {
|
None => {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"IMAP folder has no uid_next, fall back to fetching"
|
"IMAP folder {folder:?} has no uid_next, fall back to fetching."
|
||||||
);
|
);
|
||||||
// note that we use fetch by sequence number
|
// note that we use fetch by sequence number
|
||||||
// and thus we only need to get exactly the
|
// and thus we only need to get exactly the
|
||||||
@@ -685,7 +684,7 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
"uid/validity change folder {}: new {}/{} previous {}/{}",
|
"uid/validity change folder {}: new {}/{} previous {}/{}.",
|
||||||
folder,
|
folder,
|
||||||
new_uid_next,
|
new_uid_next,
|
||||||
new_uid_validity,
|
new_uid_validity,
|
||||||
@@ -706,17 +705,17 @@ impl Imap {
|
|||||||
fetch_existing_msgs: bool,
|
fetch_existing_msgs: bool,
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
if should_ignore_folder(context, folder, folder_meaning).await? {
|
if should_ignore_folder(context, folder, folder_meaning).await? {
|
||||||
info!(context, "Not fetching from {}", folder);
|
info!(context, "Not fetching from {folder:?}.");
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_emails = self
|
let new_emails = self
|
||||||
.select_with_uidvalidity(context, folder)
|
.select_with_uidvalidity(context, folder)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("failed to select folder {folder}"))?;
|
.with_context(|| format!("Failed to select folder {folder:?}"))?;
|
||||||
|
|
||||||
if !new_emails && !fetch_existing_msgs {
|
if !new_emails && !fetch_existing_msgs {
|
||||||
info!(context, "No new emails in folder {}", folder);
|
info!(context, "No new emails in folder {folder:?}.");
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -742,7 +741,7 @@ impl Imap {
|
|||||||
let headers = match get_fetch_headers(fetch_response) {
|
let headers = match get_fetch_headers(fetch_response) {
|
||||||
Ok(headers) => headers,
|
Ok(headers) => headers,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(context, "Failed to parse FETCH headers: {}", err);
|
warn!(context, "Failed to parse FETCH headers: {err:#}.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -933,7 +932,7 @@ impl Imap {
|
|||||||
if let Some(folder) = context.get_config(config).await? {
|
if let Some(folder) = context.get_config(config).await? {
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
"Fetching existing messages from folder \"{}\"", folder
|
"Fetching existing messages from folder {folder:?}."
|
||||||
);
|
);
|
||||||
self.fetch_new_messages(context, &folder, meaning, true)
|
self.fetch_new_messages(context, &folder, meaning, true)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user