@@ -3629,15 +3629,31 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul
3629
3629
}
3630
3630
3631
3631
/// Creates a group chat with a given `name`.
3632
+ /// Deprecated on 2025-06-21, use `create_group_ex()`.
3632
3633
pub async fn create_group_chat (
3633
3634
context : & Context ,
3634
3635
protect : ProtectionStatus ,
3635
- chat_name : & str ,
3636
+ name : & str ,
3636
3637
) -> Result < ChatId > {
3637
- let chat_name = sanitize_single_line ( chat_name) ;
3638
+ create_group_ex ( context, Some ( protect) , name) . await
3639
+ }
3640
+
3641
+ /// Creates a group chat.
3642
+ ///
3643
+ /// * `encryption` - If `Some`, the chat is encrypted (with key-contacts) and can be protected.
3644
+ /// * `name` - Chat name.
3645
+ pub async fn create_group_ex (
3646
+ context : & Context ,
3647
+ encryption : Option < ProtectionStatus > ,
3648
+ name : & str ,
3649
+ ) -> Result < ChatId > {
3650
+ let chat_name = sanitize_single_line ( name) ;
3638
3651
ensure ! ( !chat_name. is_empty( ) , "Invalid chat name" ) ;
3639
3652
3640
- let grpid = create_id ( ) ;
3653
+ let grpid = match encryption {
3654
+ Some ( _) => create_id ( ) ,
3655
+ None => String :: new ( ) ,
3656
+ } ;
3641
3657
3642
3658
let timestamp = create_smeared_timestamp ( context) ;
3643
3659
let row_id = context
@@ -3657,7 +3673,8 @@ pub async fn create_group_chat(
3657
3673
chatlist_events:: emit_chatlist_changed ( context) ;
3658
3674
chatlist_events:: emit_chatlist_item_changed ( context, chat_id) ;
3659
3675
3660
- if protect == ProtectionStatus :: Protected {
3676
+ if encryption == Some ( ProtectionStatus :: Protected ) {
3677
+ let protect = ProtectionStatus :: Protected ;
3661
3678
chat_id
3662
3679
. set_protection_for_timestamp_sort ( context, protect, timestamp, None )
3663
3680
. await ?;
0 commit comments