@@ -2846,8 +2846,8 @@ pub async fn is_contact_in_chat(
2846
2846
) -> Result < bool > {
2847
2847
// this function works for group and for normal chats, however, it is more useful
2848
2848
// for group chats.
2849
- // ContactId::SELF may be used to check, if the user itself is in a
2850
- // group or incoming broadcast chat
2849
+ // ContactId::SELF may be used to check whether oneself
2850
+ // is in a group or incoming broadcast chat
2851
2851
// (ContactId::SELF is not added to 1:1 chats or outgoing broadcast channels)
2852
2852
2853
2853
let exists = context
@@ -2933,7 +2933,6 @@ async fn prepare_send_msg(
2933
2933
CantSendReason :: ContactRequest => {
2934
2934
// Allow securejoin messages, they are supposed to repair the verification.
2935
2935
// If the chat is a contact request, let the user accept it later.
2936
-
2937
2936
msg. param . get_cmd ( ) == SystemMessage :: SecurejoinMessage
2938
2937
}
2939
2938
// Allow to send "Member removed" messages so we can leave the group/broadcast.
@@ -2950,7 +2949,7 @@ async fn prepare_send_msg(
2950
2949
msg. param
2951
2950
. get_bool ( Param :: ForcePlaintext )
2952
2951
. unwrap_or_default ( )
2953
- // V2 securejoin messages are symmetrically encrypted, no need for the public key:
2952
+ // "vb-request-with-auth" is symmetrically encrypted, no need for the public key:
2954
2953
|| msg. is_vb_request_with_auth ( )
2955
2954
}
2956
2955
_ => false ,
@@ -3994,7 +3993,7 @@ pub(crate) async fn remove_from_chat_contacts_table_without_trace(
3994
3993
. sql
3995
3994
. execute (
3996
3995
"DELETE FROM chats_contacts
3997
- WHERE chat_id=? AND contact_id=?" ,
3996
+ WHERE chat_id=? AND contact_id=?" ,
3998
3997
( chat_id, contact_id) ,
3999
3998
)
4000
3999
. await ?;
@@ -4038,6 +4037,10 @@ pub(crate) async fn add_contact_to_chat_ex(
4038
4037
"invalid contact_id {} for adding to group" ,
4039
4038
contact_id
4040
4039
) ;
4040
+ ensure ! (
4041
+ chat. typ != Chattype :: OutBroadcast || contact_id != ContactId :: SELF ,
4042
+ "Cannot add SELF to broadcast channel."
4043
+ ) ;
4041
4044
ensure ! (
4042
4045
chat. is_encrypted( context) . await ? == contact. is_key_contact( ) ,
4043
4046
"Only key-contacts can be added to encrypted chats"
@@ -4092,8 +4095,9 @@ pub(crate) async fn add_contact_to_chat_ex(
4092
4095
let contact_addr = contact. get_addr ( ) . to_lowercase ( ) ;
4093
4096
let added_by = if from_handshake && chat. typ == Chattype :: OutBroadcast {
4094
4097
// The contact was added via a QR code rather than explicit user action,
4095
- // and there is no useful information in saying 'You added member Alice'
4096
- // if self is the only one who can add members.
4098
+ // so it could be confusing to say 'You added member Alice'.
4099
+ // And in a broadcast, SELF is the only one who can add members,
4100
+ // so, no information is lost by just writing 'Member Alice added' instead.
4097
4101
ContactId :: UNDEFINED
4098
4102
} else {
4099
4103
ContactId :: SELF
@@ -4262,8 +4266,8 @@ pub async fn remove_contact_from_chat(
4262
4266
!contact_id. is_special( ) || contact_id == ContactId :: SELF ,
4263
4267
"Cannot remove special contact"
4264
4268
) ;
4265
- let chat = Chat :: load_from_db ( context, chat_id) . await ?;
4266
4269
4270
+ let chat = Chat :: load_from_db ( context, chat_id) . await ?;
4267
4271
if chat. typ == Chattype :: InBroadcast {
4268
4272
ensure ! (
4269
4273
contact_id == ContactId :: SELF ,
0 commit comments