mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
implement ImapResult enum like it was in C, and simplify logic a bit (with @r10s on the side)
This commit is contained in:
39
src/imap.rs
39
src/imap.rs
@@ -1284,13 +1284,7 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// All non-connection states are treated as success - the mail may
|
false
|
||||||
// already be deleted or moved away on the server.
|
|
||||||
if !self.should_reconnect() {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_seen<S: AsRef<str>>(&self, context: &Context, folder: S, uid: u32) -> ImapResult {
|
pub fn set_seen<S: AsRef<str>>(&self, context: &Context, folder: S, uid: u32) -> ImapResult {
|
||||||
@@ -1333,7 +1327,6 @@ impl Imap {
|
|||||||
if uid == 0 {
|
if uid == 0 {
|
||||||
return ImapResult::Failed;
|
return ImapResult::Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut res = ImapResult::RetryLater;
|
let mut res = ImapResult::RetryLater;
|
||||||
if self.is_connected() {
|
if self.is_connected() {
|
||||||
info!(
|
info!(
|
||||||
@@ -1405,38 +1398,30 @@ impl Imap {
|
|||||||
})
|
})
|
||||||
.unwrap_or_else(|| false);
|
.unwrap_or_else(|| false);
|
||||||
|
|
||||||
res = if flag_set {
|
if flag_set {
|
||||||
ImapResult::AlreadyDone
|
|
||||||
} else if self.add_flag(context, uid, "$MDNSent") {
|
|
||||||
ImapResult::Success
|
|
||||||
} else {
|
|
||||||
assert!(res == ImapResult::RetryLater);
|
|
||||||
res
|
|
||||||
};
|
|
||||||
|
|
||||||
if res == ImapResult::Success {
|
|
||||||
info!(context, 0, "$MDNSent just set and MDN will be sent.");
|
|
||||||
} else {
|
|
||||||
info!(context, 0, "$MDNSent already set and MDN already sent.");
|
info!(context, 0, "$MDNSent already set and MDN already sent.");
|
||||||
|
res = ImapResult::AlreadyDone;
|
||||||
|
} else if self.add_flag(context, uid, "$MDNSent") {
|
||||||
|
info!(context, 0, "$MDNSent just set and MDN will be sent.");
|
||||||
|
res = ImapResult::Success;
|
||||||
|
} else if self.should_reconnect() {
|
||||||
|
res = ImapResult::RetryLater;
|
||||||
|
} else {
|
||||||
|
res = ImapResult::Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = ImapResult::Success;
|
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
0, "Cannot store $MDNSent flags, risk sending duplicate MDN.",
|
0, "Cannot store $MDNSent flags, ignoring to prevent duplicate MDN.",
|
||||||
);
|
);
|
||||||
|
res = ImapResult::Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res == ImapResult::RetryLater && !self.should_reconnect() {
|
|
||||||
res = ImapResult::Failed
|
|
||||||
}
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
// only returns 0 on connection problems; we should try later again in this case *
|
|
||||||
pub fn delete_msg<S1: AsRef<str>, S2: AsRef<str>>(
|
pub fn delete_msg<S1: AsRef<str>, S2: AsRef<str>>(
|
||||||
&self,
|
&self,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
|
|||||||
Reference in New Issue
Block a user