mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 15:42:10 +03:00
Compare commits
20 Commits
fix_circle
...
hpk-fix-as
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
652e2c63b1 | ||
|
|
ddcd1d8919 | ||
|
|
50aa68e047 | ||
|
|
0bf32dada8 | ||
|
|
b5075a7122 | ||
|
|
3dc589788c | ||
|
|
ba2b66d07a | ||
|
|
a5a12d1f72 | ||
|
|
131f54fbf1 | ||
|
|
01fe782fa0 | ||
|
|
1077cf5e99 | ||
|
|
ca698f9164 | ||
|
|
99201027e2 | ||
|
|
d607d35abc | ||
|
|
3d790cbfca | ||
|
|
68b2707d12 | ||
|
|
6066821b50 | ||
|
|
fe695c0f95 | ||
|
|
7bf13f3f89 | ||
|
|
3b3992daed |
@@ -1,77 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
env:
|
||||
RUSTFLAGS: -Dwarnings
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
name: Build and test
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
rust: [nightly]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Install ${{ matrix.rust }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
|
||||
- name: check
|
||||
uses: actions-rs/cargo@v1
|
||||
if: matrix.rust == 'nightly'
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all
|
||||
|
||||
- name: tests ignored
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all --release -- --ignored
|
||||
|
||||
check_fmt:
|
||||
name: Checking fmt and docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt
|
||||
|
||||
- name: fmt
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
# clippy_check:
|
||||
# name: Clippy check
|
||||
# runs-on: ubuntu-latest
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# - uses: actions-rs/toolchain@v1
|
||||
# with:
|
||||
# profile: minimal
|
||||
# toolchain: nightly
|
||||
# override: true
|
||||
# components: clippy
|
||||
#
|
||||
# - name: clippy
|
||||
# run: cargo clippy --all
|
||||
@@ -32,8 +32,8 @@ if [[ $NORUN == "1" ]]; then
|
||||
export CARGO_SUBCMD="build"
|
||||
else
|
||||
export CARGO_SUBCMD="test --all"
|
||||
export OPT="-j1 ${OPT} "
|
||||
export OPT_RELEASE="-j2 ${OPT_RELEASE} "
|
||||
export OPT="${OPT} "
|
||||
export OPT_RELEASE="${OPT_RELEASE} "
|
||||
export OPT_RELEASE_IGNORED="${OPT_RELEASE} -- --ignored"
|
||||
fi
|
||||
|
||||
|
||||
58
src/imap.rs
58
src/imap.rs
@@ -312,21 +312,18 @@ impl Imap {
|
||||
return false;
|
||||
}
|
||||
|
||||
let teardown = match &mut *self.session.lock().await {
|
||||
let (teardown, can_idle, has_xlist) = match &mut *self.session.lock().await {
|
||||
Some(ref mut session) => match session.capabilities().await {
|
||||
Ok(caps) => {
|
||||
if !context.sql.is_open() {
|
||||
warn!(context, "IMAP-LOGIN as {} ok but ABORTING", lp.mail_user,);
|
||||
true
|
||||
(true, false, false)
|
||||
} else {
|
||||
let can_idle = caps.has_str("IDLE");
|
||||
let has_xlist = caps.has_str("XLIST");
|
||||
let caps_list = caps
|
||||
.iter()
|
||||
.fold(String::new(), |s, c| s + &format!(" {:?}", c));
|
||||
self.config.write().await.can_idle = can_idle;
|
||||
self.config.write().await.has_xlist = has_xlist;
|
||||
*self.connected.lock().await = true;
|
||||
emit_event!(
|
||||
context,
|
||||
Event::ImapConnected(format!(
|
||||
@@ -334,22 +331,25 @@ impl Imap {
|
||||
lp.mail_user, caps_list,
|
||||
))
|
||||
);
|
||||
false
|
||||
(false, can_idle, has_xlist)
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
info!(context, "CAPABILITY command error: {}", err);
|
||||
true
|
||||
(true, false, false)
|
||||
}
|
||||
},
|
||||
None => true,
|
||||
None => (true, false, false),
|
||||
};
|
||||
|
||||
if teardown {
|
||||
self.disconnect(context);
|
||||
|
||||
self.unsetup_handle(context).await;
|
||||
self.free_connect_params().await;
|
||||
false
|
||||
} else {
|
||||
self.config.write().await.can_idle = can_idle;
|
||||
self.config.write().await.has_xlist = has_xlist;
|
||||
*self.connected.lock().await = true;
|
||||
true
|
||||
}
|
||||
})
|
||||
@@ -746,13 +746,10 @@ impl Imap {
|
||||
pub fn idle(&self, context: &Context) {
|
||||
task::block_on(async move {
|
||||
if self.config.read().await.selected_folder.is_none() {
|
||||
// this probably means that we are in teardown
|
||||
// in any case we can't perform any idling
|
||||
return;
|
||||
}
|
||||
|
||||
if !self.config.read().await.can_idle {
|
||||
self.fake_idle(context, true).await;
|
||||
self.fake_idle(context).await;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -768,7 +765,7 @@ impl Imap {
|
||||
"idle select_folder failed {:?}",
|
||||
watch_folder.as_ref()
|
||||
);
|
||||
self.fake_idle(context, true).await;
|
||||
self.fake_idle(context).await;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -839,7 +836,7 @@ impl Imap {
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) async fn fake_idle(&self, context: &Context, use_network: bool) {
|
||||
async fn fake_idle(&self, context: &Context) {
|
||||
// Idle using timeouts. This is also needed if we're not yet configured -
|
||||
// in this case, we're waiting for a configure job
|
||||
let fake_idle_start_time = SystemTime::now();
|
||||
@@ -849,20 +846,13 @@ impl Imap {
|
||||
task::block_on(async move {
|
||||
let interrupt = stop_token::StopSource::new();
|
||||
|
||||
// we use 1000 minutes if we are told to not try network
|
||||
// which can happen because the watch_folder is not defined
|
||||
// but clients are still calling us in a loop.
|
||||
// if we are to use network, we check every minute if there
|
||||
// is new mail -- TODO: make this more flexible
|
||||
let secs = if use_network { 60 } else { 60000 };
|
||||
let interval = async_std::stream::interval(Duration::from_secs(secs));
|
||||
// TODO: More flexible interval
|
||||
let interval = async_std::stream::interval(Duration::from_secs(10));
|
||||
let mut interrupt_interval = interrupt.stop_token().stop_stream(interval);
|
||||
*self.interrupt.lock().await = Some(interrupt);
|
||||
|
||||
while let Some(_) = interrupt_interval.next().await {
|
||||
if !use_network {
|
||||
continue;
|
||||
}
|
||||
// check if we want to finish fake-idling.
|
||||
if !self.is_connected().await {
|
||||
// try to connect with proper login params
|
||||
// (setup_handle_if_needed might not know about them if we
|
||||
@@ -1164,6 +1154,13 @@ impl Imap {
|
||||
.list_folders(session, context)
|
||||
.await
|
||||
.expect("no folders found");
|
||||
let delimiter = self.config.read().await.imap_delimiter;
|
||||
let fallback_folder = format!("INBOX{}DeltaChat", delimiter);
|
||||
|
||||
let mut mvbox_folder = folders
|
||||
.iter()
|
||||
.find(|folder| folder.name() == "DeltaChat" || folder.name() == fallback_folder)
|
||||
.map(|n| n.name().to_string());
|
||||
|
||||
let sentbox_folder =
|
||||
folders
|
||||
@@ -1172,15 +1169,6 @@ impl Imap {
|
||||
FolderMeaning::SentObjects => true,
|
||||
_ => false,
|
||||
});
|
||||
info!(context, "sentbox folder is {:?}", sentbox_folder);
|
||||
|
||||
let delimiter = self.config.read().await.imap_delimiter;
|
||||
let fallback_folder = format!("INBOX{}DeltaChat", delimiter);
|
||||
|
||||
let mut mvbox_folder = folders
|
||||
.iter()
|
||||
.find(|folder| folder.name() == "DeltaChat" || folder.name() == fallback_folder)
|
||||
.map(|n| n.name().to_string());
|
||||
|
||||
if mvbox_folder.is_none() && 0 != (flags as usize & DC_CREATE_MVBOX) {
|
||||
info!(context, "Creating MVBOX-folder \"DeltaChat\"...",);
|
||||
|
||||
@@ -110,14 +110,9 @@ impl JobThread {
|
||||
if async_std::task::block_on(async move { self.imap.is_connected().await }) {
|
||||
return true;
|
||||
}
|
||||
let watch_folder_name = match context.sql.get_raw_config(context, self.folder_config_name) {
|
||||
Some(name) => name,
|
||||
None => {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
let ret_connected = dc_connect_to_configured_imap(context, &self.imap) != 0;
|
||||
let mut ret_connected = dc_connect_to_configured_imap(context, &self.imap) != 0;
|
||||
|
||||
if ret_connected {
|
||||
if context
|
||||
.sql
|
||||
@@ -128,7 +123,12 @@ impl JobThread {
|
||||
self.imap.configure_folders(context, 0x1);
|
||||
}
|
||||
|
||||
self.imap.set_watch_folder(watch_folder_name);
|
||||
if let Some(mvbox_name) = context.sql.get_raw_config(context, self.folder_config_name) {
|
||||
self.imap.set_watch_folder(mvbox_name);
|
||||
} else {
|
||||
self.imap.disconnect(context);
|
||||
ret_connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
ret_connected
|
||||
@@ -170,18 +170,10 @@ impl JobThread {
|
||||
}
|
||||
}
|
||||
|
||||
if self.connect_to_imap(context) {
|
||||
info!(context, "{}-IDLE started...", self.name,);
|
||||
self.imap.idle(context);
|
||||
info!(context, "{}-IDLE ended.", self.name);
|
||||
} else {
|
||||
// It's probably wrong that the thread even runs
|
||||
// but let's call fake_idle and tell it to not try network at all.
|
||||
// (once we move to rust-managed threads this problem goes away)
|
||||
info!(context, "{}-IDLE not connected, fake-idling", self.name);
|
||||
async_std::task::block_on(async move { self.imap.fake_idle(context, false).await });
|
||||
info!(context, "{}-IDLE fake-idling finished", self.name);
|
||||
}
|
||||
self.connect_to_imap(context);
|
||||
info!(context, "{}-IDLE started...", self.name,);
|
||||
self.imap.idle(context);
|
||||
info!(context, "{}-IDLE ended.", self.name);
|
||||
|
||||
self.state.0.lock().unwrap().using_handle = false;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ use crate::error::Error;
|
||||
use async_std::sync::Arc;
|
||||
use rustls;
|
||||
use webpki;
|
||||
use webpki_roots;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Display, FromPrimitive)]
|
||||
#[repr(i32)]
|
||||
@@ -271,10 +270,6 @@ impl rustls::ServerCertVerifier for NoCertificateVerification {
|
||||
|
||||
pub fn dc_build_tls_config(certificate_checks: CertificateChecks) -> rustls::ClientConfig {
|
||||
let mut config = rustls::ClientConfig::new();
|
||||
config
|
||||
.root_store
|
||||
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
||||
|
||||
match certificate_checks {
|
||||
CertificateChecks::Strict => {}
|
||||
CertificateChecks::Automatic => {
|
||||
|
||||
Reference in New Issue
Block a user