Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Feb 10, 2021
2 parents 80667f7 + 59f9fc7 commit 0e2fea8
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltachat"
version = "1.50.0"
version = "1.51.0-alpha.0"
authors = ["Delta Chat Developers (ML) <[email protected]>"]
edition = "2018"
license = "MPL-2.0"
Expand Down
2 changes: 1 addition & 1 deletion deltachat-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltachat_ffi"
version = "1.50.0"
version = "1.51.0-alpha.0"
description = "Deltachat FFI"
authors = ["Delta Chat Developers (ML) <[email protected]>"]
edition = "2018"
Expand Down
9 changes: 7 additions & 2 deletions python/src/deltachat/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,18 +502,23 @@ def get_locations(self, contact=None, timestamp_from=None, timestamp_to=None):
latitude=lib.dc_array_get_latitude(dc_array, i),
longitude=lib.dc_array_get_longitude(dc_array, i),
accuracy=lib.dc_array_get_accuracy(dc_array, i),
timestamp=datetime.utcfromtimestamp(lib.dc_array_get_timestamp(dc_array, i)))
timestamp=datetime.utcfromtimestamp(
lib.dc_array_get_timestamp(dc_array, i)
),
marker=from_dc_charpointer(lib.dc_array_get_marker(dc_array, i)),
)
for i in range(lib.dc_array_get_cnt(dc_array))
]


class Location:
def __init__(self, latitude, longitude, accuracy, timestamp):
def __init__(self, latitude, longitude, accuracy, timestamp, marker):
assert isinstance(timestamp, datetime)
self.latitude = latitude
self.longitude = longitude
self.accuracy = accuracy
self.timestamp = timestamp
self.marker = marker

def __eq__(self, other):
return self.__dict__ == other.__dict__
27 changes: 15 additions & 12 deletions python/src/deltachat/testplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,19 @@ def get_online_configuring_account(self, mvbox=False, sentbox=False, move=False,
def get_one_online_account(self, pre_generated_key=True, mvbox=False, move=False):
ac1 = self.get_online_configuring_account(
pre_generated_key=pre_generated_key, mvbox=mvbox, move=move)
self.wait_configure_and_start_io()
self.wait_configure_and_start_io([ac1])
return ac1

def get_two_online_accounts(self, move=False, quiet=False):
ac1 = self.get_online_configuring_account(move=move, quiet=quiet)
ac2 = self.get_online_configuring_account(quiet=quiet)
self.wait_configure_and_start_io()
self.wait_configure_and_start_io([ac1, ac2])
return ac1, ac2

def get_many_online_accounts(self, num, move=True):
accounts = [self.get_online_configuring_account(move=move, quiet=True)
for i in range(num)]
self.wait_configure_and_start_io()
self.wait_configure_and_start_io(accounts)
for acc in accounts:
acc.add_account_plugin(FFIEventLogger(acc))
return accounts
Expand Down Expand Up @@ -356,16 +356,19 @@ def clone_online_account(self, account, pre_generated_key=True):
ac._configtracker = ac.configure()
return ac

def wait_configure_and_start_io(self):
def wait_configure_and_start_io(self, accounts=None):
if accounts is None:
accounts = self._accounts[:]
started_accounts = []
for acc in self._accounts:
self.wait_configure(acc)
acc.set_config("bcc_self", "0")
if acc.is_configured() and acc not in started_accounts:
acc.start_io()
started_accounts.append(acc)
print("{}: {} account was successfully setup".format(
acc.get_config("displayname"), acc.get_config("addr")))
for acc in accounts:
if acc not in started_accounts:
self.wait_configure(acc)
acc.set_config("bcc_self", "0")
if acc.is_configured():
acc.start_io()
started_accounts.append(acc)
print("{}: {} account was started".format(
acc.get_config("displayname"), acc.get_config("addr")))
for acc in started_accounts:
acc._evtracker.wait_all_initial_fetches()

Expand Down
3 changes: 2 additions & 1 deletion python/tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ def test_send_receive_locations(self, acfactory, lp):

ac1.set_location(latitude=2.0, longitude=3.0, accuracy=0.5)
ac1._evtracker.get_matching("DC_EVENT_LOCATION_CHANGED")
chat1.send_text("hello")
chat1.send_text("🍞")
ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")

lp.sec("ac2: wait for incoming location message")
Expand All @@ -1890,6 +1890,7 @@ def test_send_receive_locations(self, acfactory, lp):
assert locations[0].longitude == 3.0
assert locations[0].accuracy == 0.5
assert locations[0].timestamp > now
assert locations[0].marker == "🍞"

contact = ac2.create_contact(ac1)
locations2 = chat2.get_locations(contact=contact)
Expand Down
26 changes: 26 additions & 0 deletions src/imap/scan_folders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl Imap {
let session = self.session.as_mut();
let session = session.context("scan_folders(): IMAP No Connection established")?;
let folders: Vec<_> = session.list(Some(""), Some("*")).await?.collect().await;
let watched_folders = get_watched_folders(context).await;

let mut sentbox_folder = None;
let mut spam_folder = None;
Expand All @@ -42,7 +43,15 @@ impl Imap {
continue;
}
};

let foldername = folder.name();
if watched_folders.contains(&foldername.to_string()) {
info!(
context,
"Not scanning folder {} as it is watched anyway", foldername
);
continue;
}
info!(context, "Scanning folder: {}", foldername);

let folder_meaning = get_folder_meaning(&folder);
Expand Down Expand Up @@ -78,3 +87,20 @@ impl Imap {
Ok(())
}
}

async fn get_watched_folders(context: &Context) -> Vec<String> {
let mut res = Vec::new();
let folder_watched_configured = &[
(Config::SentboxWatch, Config::ConfiguredSentboxFolder),
(Config::MvboxWatch, Config::ConfiguredMvboxFolder),
(Config::InboxWatch, Config::ConfiguredInboxFolder),
];
for (watched, configured) in folder_watched_configured {
if context.get_config_bool(*watched).await {
if let Some(folder) = context.get_config(*configured).await {
res.push(folder);
}
}
}
res
}

0 comments on commit 0e2fea8

Please sign in to comment.