mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 15:02:11 +03:00
Compare commits
28 Commits
hpk-fix-as
...
fix_circle
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6af272230e | ||
|
|
9c81ccfd09 | ||
|
|
895b01f537 | ||
|
|
58ad14d9c3 | ||
|
|
e539bddc3b | ||
|
|
2fc1d21959 | ||
|
|
b43d9d2ffe | ||
|
|
5b73951b9b | ||
|
|
8595b92fcf | ||
|
|
6054b90975 | ||
|
|
b8427ab56e | ||
|
|
02f72eea61 | ||
|
|
a5a20078f0 | ||
|
|
7383094b33 | ||
|
|
e225a6fb17 | ||
|
|
6bdc207277 | ||
|
|
101141c67a | ||
|
|
d07afe5bd6 | ||
|
|
00e22d4339 | ||
|
|
91c8f48c21 | ||
|
|
3d76d21925 | ||
|
|
3349c0e9dc | ||
|
|
7b35104b83 | ||
|
|
22b6e8f6e2 | ||
|
|
ad118aa0df | ||
|
|
9044b80b9f | ||
|
|
b948e973c5 | ||
|
|
d330d890c0 |
77
ci_scripts/gh-actions-rust.yml
Normal file
77
ci_scripts/gh-actions-rust.yml
Normal file
@@ -0,0 +1,77 @@
|
||||
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="${OPT} "
|
||||
export OPT_RELEASE="${OPT_RELEASE} "
|
||||
export OPT="-j1 ${OPT} "
|
||||
export OPT_RELEASE="-j2 ${OPT_RELEASE} "
|
||||
export OPT_RELEASE_IGNORED="${OPT_RELEASE} -- --ignored"
|
||||
fi
|
||||
|
||||
|
||||
58
src/imap.rs
58
src/imap.rs
@@ -312,18 +312,21 @@ impl Imap {
|
||||
return false;
|
||||
}
|
||||
|
||||
let (teardown, can_idle, has_xlist) = match &mut *self.session.lock().await {
|
||||
let teardown = 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, false, false)
|
||||
true
|
||||
} 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!(
|
||||
@@ -331,25 +334,22 @@ impl Imap {
|
||||
lp.mail_user, caps_list,
|
||||
))
|
||||
);
|
||||
(false, can_idle, has_xlist)
|
||||
false
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
info!(context, "CAPABILITY command error: {}", err);
|
||||
(true, false, false)
|
||||
true
|
||||
}
|
||||
},
|
||||
None => (true, false, false),
|
||||
None => true,
|
||||
};
|
||||
|
||||
if teardown {
|
||||
self.unsetup_handle(context).await;
|
||||
self.free_connect_params().await;
|
||||
self.disconnect(context);
|
||||
|
||||
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,10 +746,13 @@ 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).await;
|
||||
self.fake_idle(context, true).await;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -765,7 +768,7 @@ impl Imap {
|
||||
"idle select_folder failed {:?}",
|
||||
watch_folder.as_ref()
|
||||
);
|
||||
self.fake_idle(context).await;
|
||||
self.fake_idle(context, true).await;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -836,7 +839,7 @@ impl Imap {
|
||||
});
|
||||
}
|
||||
|
||||
async fn fake_idle(&self, context: &Context) {
|
||||
pub(crate) async fn fake_idle(&self, context: &Context, use_network: bool) {
|
||||
// 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();
|
||||
@@ -846,13 +849,20 @@ impl Imap {
|
||||
task::block_on(async move {
|
||||
let interrupt = stop_token::StopSource::new();
|
||||
|
||||
// TODO: More flexible interval
|
||||
let interval = async_std::stream::interval(Duration::from_secs(10));
|
||||
// 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));
|
||||
let mut interrupt_interval = interrupt.stop_token().stop_stream(interval);
|
||||
*self.interrupt.lock().await = Some(interrupt);
|
||||
|
||||
while let Some(_) = interrupt_interval.next().await {
|
||||
// check if we want to finish fake-idling.
|
||||
if !use_network {
|
||||
continue;
|
||||
}
|
||||
if !self.is_connected().await {
|
||||
// try to connect with proper login params
|
||||
// (setup_handle_if_needed might not know about them if we
|
||||
@@ -1154,13 +1164,6 @@ 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
|
||||
@@ -1169,6 +1172,15 @@ 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,9 +110,14 @@ 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 mut ret_connected = dc_connect_to_configured_imap(context, &self.imap) != 0;
|
||||
|
||||
let ret_connected = dc_connect_to_configured_imap(context, &self.imap) != 0;
|
||||
if ret_connected {
|
||||
if context
|
||||
.sql
|
||||
@@ -123,12 +128,7 @@ impl JobThread {
|
||||
self.imap.configure_folders(context, 0x1);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
self.imap.set_watch_folder(watch_folder_name);
|
||||
}
|
||||
|
||||
ret_connected
|
||||
@@ -170,10 +170,18 @@ impl JobThread {
|
||||
}
|
||||
}
|
||||
|
||||
self.connect_to_imap(context);
|
||||
info!(context, "{}-IDLE started...", self.name,);
|
||||
self.imap.idle(context);
|
||||
info!(context, "{}-IDLE ended.", self.name);
|
||||
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.state.0.lock().unwrap().using_handle = false;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::error::Error;
|
||||
use async_std::sync::Arc;
|
||||
use rustls;
|
||||
use webpki;
|
||||
use webpki_roots;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Display, FromPrimitive)]
|
||||
#[repr(i32)]
|
||||
@@ -270,6 +271,10 @@ 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