@@ -114,7 +114,24 @@ pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Resul
114
114
chat:: add_info_msg ( context, group_chat_id, & msg, time ( ) ) . await ?;
115
115
Ok ( group_chat_id)
116
116
}
117
- QrInvite :: Broadcast { .. } => { }
117
+ QrInvite :: Broadcast { .. } => {
118
+ // For a secure-join we need to create the group and add the contact. The group will
119
+ // only become usable once the protocol is finished.
120
+ let group_chat_id = joining_chat_id ( context, & invite, chat_id) . await ?;
121
+ if !is_contact_in_chat ( context, group_chat_id, invite. contact_id ( ) ) . await ? {
122
+ chat:: add_to_chat_contacts_table (
123
+ context,
124
+ time ( ) ,
125
+ group_chat_id,
126
+ & [ invite. contact_id ( ) ] ,
127
+ )
128
+ . await ?;
129
+ }
130
+ // TODO this message should be translatable:
131
+ let msg = "You were invited to join this channel. Waiting for the channel owner's device to reply…" ;
132
+ chat:: add_info_msg ( context, group_chat_id, msg, time ( ) ) . await ?;
133
+ Ok ( group_chat_id)
134
+ }
118
135
QrInvite :: Contact { .. } => {
119
136
// For setup-contact the BobState already ensured the 1:1 chat exists because it
120
137
// uses it to send the handshake messages.
@@ -206,7 +223,7 @@ pub(super) async fn handle_auth_required(
206
223
. await ?;
207
224
208
225
match invite {
209
- QrInvite :: Contact { .. } => { }
226
+ QrInvite :: Contact { .. } | QrInvite :: Broadcast { .. } => { }
210
227
QrInvite :: Group { .. } => {
211
228
// The message reads "Alice replied, waiting to be added to the group…",
212
229
// so only show it on secure-join and not on setup-contact.
@@ -325,10 +342,14 @@ impl BobHandshakeMsg {
325
342
Self :: Request => match invite {
326
343
QrInvite :: Contact { .. } => "vc-request" ,
327
344
QrInvite :: Group { .. } => "vg-request" ,
345
+ QrInvite :: Broadcast { .. } => "broadcast-request" ,
328
346
} ,
329
347
Self :: RequestWithAuth => match invite {
330
348
QrInvite :: Contact { .. } => "vc-request-with-auth" ,
331
349
QrInvite :: Group { .. } => "vg-request-with-auth" ,
350
+ QrInvite :: Broadcast { .. } => {
351
+ panic ! ( "There is no request-with-auth for broadcasts" )
352
+ } // TODO remove panic
332
353
} ,
333
354
}
334
355
}
@@ -348,16 +369,27 @@ async fn joining_chat_id(
348
369
) -> Result < ChatId > {
349
370
match invite {
350
371
QrInvite :: Contact { .. } => Ok ( alice_chat_id) ,
351
- QrInvite :: Group { grpid, name, .. } => {
352
- let group_chat_id = match chat:: get_chat_id_by_grpid ( context, grpid) . await ? {
372
+ QrInvite :: Group { grpid, name, .. }
373
+ | QrInvite :: Broadcast {
374
+ broadcast_name : name,
375
+ grpid,
376
+ ..
377
+ } => {
378
+ let chattype = if matches ! ( invite, QrInvite :: Group { .. } ) {
379
+ Chattype :: Group
380
+ } else {
381
+ Chattype :: InBroadcast
382
+ } ;
383
+
384
+ let chat_id = match chat:: get_chat_id_by_grpid ( context, grpid) . await ? {
353
385
Some ( ( chat_id, _protected, _blocked) ) => {
354
386
chat_id. unblock_ex ( context, Nosync ) . await ?;
355
387
chat_id
356
388
}
357
389
None => {
358
390
ChatId :: create_multiuser_record (
359
391
context,
360
- Chattype :: Group ,
392
+ chattype ,
361
393
grpid,
362
394
name,
363
395
Blocked :: Not ,
@@ -368,7 +400,7 @@ async fn joining_chat_id(
368
400
. await ?
369
401
}
370
402
} ;
371
- Ok ( group_chat_id )
403
+ Ok ( chat_id )
372
404
}
373
405
}
374
406
}
0 commit comments