@@ -3570,15 +3570,31 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul
3570
3570
}
3571
3571
3572
3572
/// Creates a group chat with a given `name`.
3573
+ /// Deprecated on 2025-06-21, use `create_group_ex()`.
3573
3574
pub async fn create_group_chat (
3574
3575
context : & Context ,
3575
3576
protect : ProtectionStatus ,
3576
- chat_name : & str ,
3577
+ name : & str ,
3577
3578
) -> Result < ChatId > {
3578
- let chat_name = sanitize_single_line ( chat_name) ;
3579
+ create_group_ex ( context, Some ( protect) , name) . await
3580
+ }
3581
+
3582
+ /// Creates a group chat.
3583
+ ///
3584
+ /// * `encryption` - If `Some`, the chat is encrypted (with PGP contacts) and can be protected.
3585
+ /// * `name` - Chat name.
3586
+ pub async fn create_group_ex (
3587
+ context : & Context ,
3588
+ encryption : Option < ProtectionStatus > ,
3589
+ name : & str ,
3590
+ ) -> Result < ChatId > {
3591
+ let chat_name = sanitize_single_line ( name) ;
3579
3592
ensure ! ( !chat_name. is_empty( ) , "Invalid chat name" ) ;
3580
3593
3581
- let grpid = create_id ( ) ;
3594
+ let grpid = match encryption {
3595
+ Some ( _) => create_id ( ) ,
3596
+ None => String :: new ( ) ,
3597
+ } ;
3582
3598
3583
3599
let timestamp = create_smeared_timestamp ( context) ;
3584
3600
let row_id = context
@@ -3598,7 +3614,8 @@ pub async fn create_group_chat(
3598
3614
chatlist_events:: emit_chatlist_changed ( context) ;
3599
3615
chatlist_events:: emit_chatlist_item_changed ( context, chat_id) ;
3600
3616
3601
- if protect == ProtectionStatus :: Protected {
3617
+ if encryption == Some ( ProtectionStatus :: Protected ) {
3618
+ let protect = ProtectionStatus :: Protected ;
3602
3619
chat_id
3603
3620
. set_protection_for_timestamp_sort ( context, protect, timestamp, None )
3604
3621
. await ?;
0 commit comments