Skip to content

Commit 1dcec1b

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 416131b commit 1dcec1b

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
@@ -3570,15 +3570,31 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul
35703570
}
35713571

35723572
/// Creates a group chat with a given `name`.
3573+
/// Deprecated on 2025-06-21, use `create_group_ex()`.
35733574
pub async fn create_group_chat(
35743575
context: &Context,
35753576
protect: ProtectionStatus,
3576-
chat_name: &str,
3577+
name: &str,
35773578
) -> 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);
35793592
ensure!(!chat_name.is_empty(), "Invalid chat name");
35803593

3581-
let grpid = create_id();
3594+
let grpid = match encryption {
3595+
Some(_) => create_id(),
3596+
None => String::new(),
3597+
};
35823598

35833599
let timestamp = create_smeared_timestamp(context);
35843600
let row_id = context
@@ -3598,7 +3614,8 @@ pub async fn create_group_chat(
35983614
chatlist_events::emit_chatlist_changed(context);
35993615
chatlist_events::emit_chatlist_item_changed(context, chat_id);
36003616

3601-
if protect == ProtectionStatus::Protected {
3617+
if encryption == Some(ProtectionStatus::Protected) {
3618+
let protect = ProtectionStatus::Protected;
36023619
chat_id
36033620
.set_protection_for_timestamp_sort(context, protect, timestamp, None)
36043621
.await?;

0 commit comments

Comments
 (0)