@@ -121,14 +121,14 @@ impl CommandApi {
121121 }
122122 }
123123
124+ async fn get_context_opt ( & self , id : u32 ) -> Option < deltachat:: context:: Context > {
125+ self . accounts . read ( ) . await . get_account ( id)
126+ }
127+
124128 async fn get_context ( & self , id : u32 ) -> Result < deltachat:: context:: Context > {
125- let sc = self
126- . accounts
127- . read ( )
129+ self . get_context_opt ( id)
128130 . await
129- . get_account ( id)
130- . ok_or_else ( || anyhow ! ( "account with id {id} not found" ) ) ?;
131- Ok ( sc)
131+ . ok_or_else ( || anyhow ! ( "account with id {id} not found" ) )
132132 }
133133
134134 async fn with_state < F , T > ( & self , id : u32 , with_state : F ) -> T
@@ -1307,13 +1307,18 @@ impl CommandApi {
13071307 ///
13081308 /// Returns IDs of existing messages.
13091309 async fn get_existing_msg_ids ( & self , account_id : u32 , msg_ids : Vec < u32 > ) -> Result < Vec < u32 > > {
1310- let context = self . get_context ( account_id) . await ?;
1311- let msg_ids: Vec < MsgId > = msg_ids. into_iter ( ) . map ( MsgId :: new) . collect ( ) ;
1312- let existing_msg_ids = get_existing_msg_ids ( & context, & msg_ids) . await ?;
1313- Ok ( existing_msg_ids
1314- . into_iter ( )
1315- . map ( |msg_id| msg_id. to_u32 ( ) )
1316- . collect ( ) )
1310+ if let Some ( context) = self . get_context_opt ( account_id) . await {
1311+ let msg_ids: Vec < MsgId > = msg_ids. into_iter ( ) . map ( MsgId :: new) . collect ( ) ;
1312+ let existing_msg_ids = get_existing_msg_ids ( & context, & msg_ids) . await ?;
1313+ Ok ( existing_msg_ids
1314+ . into_iter ( )
1315+ . map ( |msg_id| msg_id. to_u32 ( ) )
1316+ . collect ( ) )
1317+ } else {
1318+ // Account does not exist, so messages do not exist either,
1319+ // but this is not an error.
1320+ Ok ( Vec :: new ( ) )
1321+ }
13171322 }
13181323
13191324 async fn get_message_list_items (
0 commit comments