mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
feat: add is_muted config option
This commit is contained in:
@@ -519,6 +519,11 @@ char* dc_get_blobdir (const dc_context_t* context);
|
|||||||
* 1=After the key changed, `dc_chat_can_send()` returns false and `dc_chat_is_protection_broken()` returns true
|
* 1=After the key changed, `dc_chat_can_send()` returns false and `dc_chat_is_protection_broken()` returns true
|
||||||
* until `dc_accept_chat()` is called.
|
* until `dc_accept_chat()` is called.
|
||||||
* - `is_chatmail` = 1 if the the server is a chatmail server, 0 otherwise.
|
* - `is_chatmail` = 1 if the the server is a chatmail server, 0 otherwise.
|
||||||
|
* - `is_muted` = Whether a context is muted by the user.
|
||||||
|
* Muted contexts should not sound, vibrate or show notifications.
|
||||||
|
* In contrast to `dc_set_chat_mute_duration()`,
|
||||||
|
* fresh message and badge counters are not changed by this setting,
|
||||||
|
* but should be tuned down where appropriate.
|
||||||
* - `ui.*` = All keys prefixed by `ui.` can be used by the user-interfaces for system-specific purposes.
|
* - `ui.*` = All keys prefixed by `ui.` can be used by the user-interfaces for system-specific purposes.
|
||||||
* The prefix should be followed by the system and maybe subsystem,
|
* The prefix should be followed by the system and maybe subsystem,
|
||||||
* e.g. `ui.desktop.foo`, `ui.desktop.linux.bar`, `ui.android.foo`, `ui.dc40.bar`, `ui.bot.simplebot.baz`.
|
* e.g. `ui.desktop.foo`, `ui.desktop.linux.bar`, `ui.android.foo`, `ui.dc40.bar`, `ui.bot.simplebot.baz`.
|
||||||
|
|||||||
@@ -257,6 +257,9 @@ pub enum Config {
|
|||||||
/// True if account is a chatmail account.
|
/// True if account is a chatmail account.
|
||||||
IsChatmail,
|
IsChatmail,
|
||||||
|
|
||||||
|
/// True if account is muted.
|
||||||
|
IsMuted,
|
||||||
|
|
||||||
/// All secondary self addresses separated by spaces
|
/// All secondary self addresses separated by spaces
|
||||||
/// (`addr1@example.org addr2@example.org addr3@example.org`)
|
/// (`addr1@example.org addr2@example.org addr3@example.org`)
|
||||||
SecondaryAddrs,
|
SecondaryAddrs,
|
||||||
|
|||||||
@@ -814,6 +814,10 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.insert("is_chatmail", self.is_chatmail().await?.to_string());
|
res.insert("is_chatmail", self.is_chatmail().await?.to_string());
|
||||||
|
res.insert(
|
||||||
|
"is_muted",
|
||||||
|
self.get_config_bool(Config::IsMuted).await?.to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
if let Some(metadata) = &*self.metadata.read().await {
|
if let Some(metadata) = &*self.metadata.read().await {
|
||||||
if let Some(comment) = &metadata.comment {
|
if let Some(comment) = &metadata.comment {
|
||||||
@@ -1550,6 +1554,22 @@ mod tests {
|
|||||||
assert_eq!(t.get_fresh_msgs().await.unwrap().len(), 1);
|
assert_eq!(t.get_fresh_msgs().await.unwrap().len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_muted_context() -> Result<()> {
|
||||||
|
let t = TestContext::new_alice().await;
|
||||||
|
assert_eq!(t.get_fresh_msgs().await.unwrap().len(), 0);
|
||||||
|
t.set_config(Config::IsMuted, Some("1")).await?;
|
||||||
|
let chat = t.create_chat_with_contact("", "bob@g.it").await;
|
||||||
|
receive_msg(&t, &chat).await;
|
||||||
|
|
||||||
|
// muted contexts should still show dimmed badge counters eg. in the sidebars,
|
||||||
|
// (same as muted chats show dimmed badge counters in the chatlist)
|
||||||
|
// therefore the fresh messages count should not be affected.
|
||||||
|
assert_eq!(t.get_fresh_msgs().await.unwrap().len(), 1);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_blobdir_exists() {
|
async fn test_blobdir_exists() {
|
||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user