@@ -3657,15 +3657,31 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul
3657
3657
}
3658
3658
3659
3659
/// Creates a group chat with a given `name`.
3660
+ /// Deprecated on 2025-06-21, use `create_group_ex()`.
3660
3661
pub async fn create_group_chat (
3661
3662
context : & Context ,
3662
3663
protect : ProtectionStatus ,
3663
- chat_name : & str ,
3664
+ name : & str ,
3664
3665
) -> Result < ChatId > {
3665
- let chat_name = sanitize_single_line ( chat_name) ;
3666
+ create_group_ex ( context, Some ( protect) , name) . await
3667
+ }
3668
+
3669
+ /// Creates a group chat.
3670
+ ///
3671
+ /// * `encryption` - If `Some`, the chat is encrypted (with key-contacts) and can be protected.
3672
+ /// * `name` - Chat name.
3673
+ pub async fn create_group_ex (
3674
+ context : & Context ,
3675
+ encryption : Option < ProtectionStatus > ,
3676
+ name : & str ,
3677
+ ) -> Result < ChatId > {
3678
+ let chat_name = sanitize_single_line ( name) ;
3666
3679
ensure ! ( !chat_name. is_empty( ) , "Invalid chat name" ) ;
3667
3680
3668
- let grpid = create_id ( ) ;
3681
+ let grpid = match encryption {
3682
+ Some ( _) => create_id ( ) ,
3683
+ None => String :: new ( ) ,
3684
+ } ;
3669
3685
3670
3686
let timestamp = create_smeared_timestamp ( context) ;
3671
3687
let row_id = context
@@ -3685,7 +3701,8 @@ pub async fn create_group_chat(
3685
3701
chatlist_events:: emit_chatlist_changed ( context) ;
3686
3702
chatlist_events:: emit_chatlist_item_changed ( context, chat_id) ;
3687
3703
3688
- if protect == ProtectionStatus :: Protected {
3704
+ if encryption == Some ( ProtectionStatus :: Protected ) {
3705
+ let protect = ProtectionStatus :: Protected ;
3689
3706
chat_id
3690
3707
. set_protection_for_timestamp_sort ( context, protect, timestamp, None )
3691
3708
. await ?;
0 commit comments