mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
broadcasts (#2707)
* add Chattype::Broadcast and create_broadcast_list() * do not disclose recipients for broadcasts * allow sending/add-/remove-member for broadcast * set broadcast subject same as for one-to-one chats * broadcast-recipient-list does not include SELF * use special icon for broadcast groups * generate initial broadcast names * make clippy happy * send BCC message unencrypted to avoid unexpected disclosing; encryption is opportunistic anyway. if we have 'protected chats' at some point, we can think that over. * reword 'To:'-group * simplify can-send-check * add broadcast tests * tweak comments * Update deltachat-ffi/deltachat.h Co-authored-by: Hocuri <hocuri@gmx.de> * change name of can_edit() to is_self_in_chat() Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
@@ -1299,6 +1299,8 @@ void dc_accept_chat (dc_context_t* context, uint32_t ch
|
||||
* explicitly as it may happen that oneself gets removed from a still existing
|
||||
* group
|
||||
*
|
||||
* - for broadcasts, all recipients are returned, DC_CONTACT_ID_SELF is not included
|
||||
*
|
||||
* - for mailing lists, the behavior is not documented currently, we will decide on that later.
|
||||
* for now, the UI should not show the list for mailing lists.
|
||||
* (we do not know all members and there is not always a global mailing list address,
|
||||
@@ -1408,6 +1410,36 @@ dc_chat_t* dc_get_chat (dc_context_t* context, uint32_t ch
|
||||
uint32_t dc_create_group_chat (dc_context_t* context, int protect, const char* name);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new broadcast list.
|
||||
*
|
||||
* Broadcast lists are similar to groups on the sending device,
|
||||
* however, recipients get the messages in normal one-to-one chats
|
||||
* and will not be aware of other members.
|
||||
*
|
||||
* Replies to broadcasts go only to the sender
|
||||
* and not to all broadcast recipients.
|
||||
* Moreover, replies will not appear in the broadcast list
|
||||
* but in the one-to-one chat with the person answering.
|
||||
*
|
||||
* The name and the image of the broadcast list is set automatically
|
||||
* and is visible to the sender only.
|
||||
* Not asking for these data allows more focused creation
|
||||
* and we bypass the question who will get which data.
|
||||
* Also, many users will have at most one broadcast list
|
||||
* so, a generic name and image is sufficient at the first place.
|
||||
*
|
||||
* Later on, however, the name can be changed using dc_set_chat_name().
|
||||
* The image cannot be changed to have a unique, recognizable icon in the chat lists.
|
||||
* All in all, this is also what other messengers are doing here.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object.
|
||||
* @return The chat ID of the new broadcast list, 0 on errors.
|
||||
*/
|
||||
uint32_t dc_create_broadcast_list (dc_context_t* context);
|
||||
|
||||
|
||||
/**
|
||||
* Check if a given contact ID is a member of a group chat.
|
||||
*
|
||||
@@ -3044,6 +3076,11 @@ uint32_t dc_chat_get_id (const dc_chat_t* chat);
|
||||
* and cannot be changed using this api.
|
||||
* moreover, for now, mailist lists are read-only.
|
||||
*
|
||||
* - @ref DC_CHAT_TYPE_BROADCAST - a broadcast list,
|
||||
* the recipients will get messages in a one-to-one chats and
|
||||
* the sender will get answers in a one-to-one as well.
|
||||
* chats_contacts contain all recipients but DC_CONTACT_ID_SELF
|
||||
*
|
||||
* @memberof dc_chat_t
|
||||
* @param chat The chat object.
|
||||
* @return Chat type.
|
||||
@@ -4744,6 +4781,11 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot);
|
||||
*/
|
||||
#define DC_CHAT_TYPE_MAILINGLIST 140
|
||||
|
||||
/**
|
||||
* A broadcast list. See dc_chat_get_type() for details.
|
||||
*/
|
||||
#define DC_CHAT_TYPE_BROADCAST 160
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -5967,6 +6009,11 @@ void dc_event_unref(dc_event_t* event);
|
||||
/// Used as a subtitle in quota context; can be plural always.
|
||||
#define DC_STR_MESSAGES 114
|
||||
|
||||
/// "Broadcast List"
|
||||
///
|
||||
/// Used as the default name for broadcast lists; a number may be added.
|
||||
#define DC_STR_BROADCAST_LIST 115
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -1330,6 +1330,19 @@ pub unsafe extern "C" fn dc_create_group_chat(
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_create_broadcast_list(context: *mut dc_context_t) -> u32 {
|
||||
if context.is_null() {
|
||||
eprintln!("ignoring careless call to dc_create_broadcast_list()");
|
||||
return 0;
|
||||
}
|
||||
let ctx = &*context;
|
||||
block_on(chat::create_broadcast_list(ctx))
|
||||
.log_err(ctx, "Failed to create broadcast list")
|
||||
.map(|id| id.to_u32())
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_is_contact_in_chat(
|
||||
context: *mut dc_context_t,
|
||||
|
||||
Reference in New Issue
Block a user