Skip to content

Commit 10bcb90

Browse files
committed
api: Add chat::create_group_ex(), deprecate create_group_chat() (#6927)
`chat::create_group_ex()` gains an `encryption: Option<ProtectionStatus>` parameter to support unencrypted chats.
1 parent f5e8c80 commit 10bcb90

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/chat.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,15 +3629,31 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul
36293629
}
36303630

36313631
/// Creates a group chat with a given `name`.
3632+
/// Deprecated on 2025-06-21, use `create_group_ex()`.
36323633
pub async fn create_group_chat(
36333634
context: &Context,
36343635
protect: ProtectionStatus,
3635-
chat_name: &str,
3636+
name: &str,
36363637
) -> 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 PGP 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);
36383651
ensure!(!chat_name.is_empty(), "Invalid chat name");
36393652

3640-
let grpid = create_id();
3653+
let grpid = match encryption {
3654+
Some(_) => create_id(),
3655+
None => String::new(),
3656+
};
36413657

36423658
let timestamp = create_smeared_timestamp(context);
36433659
let row_id = context
@@ -3657,7 +3673,8 @@ pub async fn create_group_chat(
36573673
chatlist_events::emit_chatlist_changed(context);
36583674
chatlist_events::emit_chatlist_item_changed(context, chat_id);
36593675

3660-
if protect == ProtectionStatus::Protected {
3676+
if encryption == Some(ProtectionStatus::Protected) {
3677+
let protect = ProtectionStatus::Protected;
36613678
chat_id
36623679
.set_protection_for_timestamp_sort(context, protect, timestamp, None)
36633680
.await?;

0 commit comments

Comments
 (0)