Skip to content

Commit 2f3e446

Browse files
committed
feat: add is_chatmail
1 parent 251c2c6 commit 2f3e446

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/self_reporting.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct Statistics {
2525
core_version: String,
2626
key_created: i64,
2727
self_reporting_id: String,
28+
is_chatmail: bool,
2829
contact_stats: Vec<ContactStat>,
2930
message_stats: MessageStats,
3031
securejoin_source_stats: SecurejoinSourceStats,
@@ -186,6 +187,7 @@ async fn get_self_report(context: &Context) -> Result<String> {
186187
core_version: get_version_str().to_string(),
187188
key_created,
188189
self_reporting_id,
190+
is_chatmail: context.is_chatmail().await?,
189191
contact_stats: get_contact_stats(context).await?,
190192
message_stats: get_message_stats(context, last_msgid).await?, // TODO
191193
securejoin_source_stats: get_securejoin_source_stats(context).await?,

src/self_reporting/self_reporting_tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,21 @@ async fn check_securejoin_report(context: &TestContext, expected: &SecurejoinSou
250250

251251
assert_eq!(actual, &expected);
252252
}
253+
254+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
255+
async fn test_self_report_is_chatmail() -> Result<()> {
256+
let alice = &TestContext::new_alice().await;
257+
alice.set_config_bool(Config::SelfReporting, true).await?;
258+
259+
let r = get_self_report(alice).await?;
260+
let r: serde_json::Value = serde_json::from_str(&r)?;
261+
assert_eq!(r.get("is_chatmail").unwrap().as_bool().unwrap(), false);
262+
263+
alice.set_config_bool(Config::IsChatmail, true).await?;
264+
265+
let r = get_self_report(alice).await?;
266+
let r: serde_json::Value = serde_json::from_str(&r)?;
267+
assert_eq!(r.get("is_chatmail").unwrap().as_bool().unwrap(), true);
268+
269+
Ok(())
270+
}

0 commit comments

Comments
 (0)