@@ -17,7 +17,7 @@ use serde::Serialize;
17
17
use tokio:: sync:: { Mutex , Notify , RwLock } ;
18
18
19
19
use crate :: aheader:: EncryptPreference ;
20
- use crate :: chat:: { get_chat_cnt, ChatId , ProtectionStatus } ;
20
+ use crate :: chat:: { self , get_chat_cnt, ChatId , ChatVisibility , MuteDuration , ProtectionStatus } ;
21
21
use crate :: chatlist_events;
22
22
use crate :: config:: Config ;
23
23
use crate :: constants:: {
@@ -1200,7 +1200,17 @@ impl Context {
1200
1200
const SELF_REPORTING_BOT : & str = "self_reporting@testrun.org" ;
1201
1201
1202
1202
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
+ } ;
1204
1214
1205
1215
// We're including the bot's public key in Delta Chat
1206
1216
// so that the first message to the bot can directly be encrypted:
0 commit comments