Skip to content

Commit fd0aea1

Browse files
committed
inviteUser should return an object
1 parent 7fcd0bd commit fd0aea1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/cloud/social/provider.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ export class CloudSocialProvider {
342342
// Returns a new invite code for the specified server.
343343
// Rejects if the user is not logged in as an admin or there
344344
// is any error executing the command.
345-
public inviteUser = (clientId: string): Promise<string> => {
345+
// TODO: typings for invite codes
346+
public inviteUser = (clientId: string): Promise<Object> => {
346347
log.debug('inviteUser');
347348
if (!(clientId in this.clients_)) {
348349
return Promise.reject(new Error('unknown client ' + clientId));
@@ -352,7 +353,7 @@ export class CloudSocialProvider {
352353
this.savedContacts_[clientId].invite.user));
353354
}
354355
return this.clients_[clientId].then((connection: Connection) => {
355-
return connection.getBanner();
356+
return connection.issueInvite();
356357
});
357358
}
358359

@@ -545,9 +546,11 @@ class Connection {
545546
return this.exec_('cat /banner');
546547
}
547548

548-
// Issues a new invite code.
549-
public issueInvite = (): Promise<string> => {
550-
return this.exec_('sudo /issue_invite.sh');
549+
// Returns a base64-decoded, deserialised invite code.
550+
public issueInvite = (): Promise<Object> => {
551+
return this.exec_('sudo /issue_invite.sh').then((inviteCode: string) => {
552+
return JSON.parse(new Buffer(inviteCode, 'base64').toString());
553+
});
551554
}
552555

553556
// Executes a command, fulfilling with the command's stdout

0 commit comments

Comments
 (0)