@@ -404,21 +404,28 @@ export class CloudSocialProvider {
404404 } ) ;
405405 }
406406
407- // Parses an invite code, received from uProxy in JSON format.
408- // This is the networkData field of the invite codes distributed
409- // to uProxy users.
407+ // Parses the networkData field, serialised to JSON, of invites.
408+ // The contact is immediately saved and added to the contacts list.
410409 public acceptUserInvitation = ( inviteJson : string ) : Promise < void > => {
411410 log . debug ( 'acceptUserInvitation' ) ;
412411 try {
413- var invite = < Invite > JSON . parse ( inviteJson ) ;
414- log . debug ( 'decoded invite: %1' , invite ) ;
415- return this . reconnect_ ( invite ) . then ( ( connection : Connection ) => {
416- // Return nothing for type checking purposes.
412+ const invite = < Invite > JSON . parse ( inviteJson ) ;
413+
414+ this . notifyOfUser_ ( invite ) ;
415+ this . savedContacts_ [ invite . host ] = {
416+ invite : invite
417+ } ;
418+ this . saveContacts_ ( ) ;
419+
420+ // Connect in the background in order to fetch metadata such as
421+ // the banner (description).
422+ this . reconnect_ ( invite ) . catch ( ( e : Error ) => {
423+ log . warn ( 'failed to log into cloud server during invite accept: %1' , e . message ) ;
417424 } ) ;
425+
426+ return Promise . resolve < void > ( ) ;
418427 } catch ( e ) {
419- return Promise . reject ( {
420- message : 'could not parse invite code: ' + e . message
421- } ) ;
428+ return Promise . reject ( new Error ( 'could not parse invite code: ' + e . message ) ) ;
422429 }
423430 }
424431
0 commit comments