@@ -17,7 +17,7 @@ use serde::Serialize;
1717use tokio:: sync:: { Mutex , Notify , RwLock } ;
1818
1919use crate :: aheader:: EncryptPreference ;
20- use crate :: chat:: { get_chat_cnt, ChatId , ProtectionStatus } ;
20+ use crate :: chat:: { self , get_chat_cnt, ChatId , ChatVisibility , MuteDuration , ProtectionStatus } ;
2121use crate :: chatlist_events;
2222use crate :: config:: Config ;
2323use crate :: constants:: {
@@ -1200,7 +1200,17 @@ impl Context {
12001200 const SELF_REPORTING_BOT : & str = "self_reporting@testrun.org" ;
12011201
12021202 let contact_id = Contact :: create ( self , "Statistics bot" , SELF_REPORTING_BOT ) . await ?;
1203- let chat_id = ChatId :: create_for_contact ( self , contact_id) . await ?;
1203+ let chat_id = if let Some ( res) = ChatId :: lookup_by_contact ( self , contact_id) . await ? {
1204+ // Already exists, no need to create.
1205+ res
1206+ } else {
1207+ let chat_id = ChatId :: get_for_contact ( self , contact_id) . await ?;
1208+ chat_id
1209+ . set_visibility ( self , ChatVisibility :: Archived )
1210+ . await ?;
1211+ chat:: set_muted ( self , chat_id, MuteDuration :: Forever ) . await ?;
1212+ chat_id
1213+ } ;
12041214
12051215 // We're including the bot's public key in Delta Chat
12061216 // so that the first message to the bot can directly be encrypted:
0 commit comments