Skip to content

Commit

Permalink
Merge pull request RocketChat#24 from WideChat/karan_fix_invite_email
Browse files Browse the repository at this point in the history
Fix Invite via Email to return appropriate response
  • Loading branch information
jaytat0 authored Jan 29, 2019
2 parents c568e7e + c4f846b commit 950f577
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/rocketchat-api/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Package.onUse(function(api) {
'rocketchat:lib',
'rocketchat:integrations',
'rocketchat:file-upload',
'rocketchat:mailer',
]);

api.mainModule('server/index.js', 'server');
Expand Down
15 changes: 8 additions & 7 deletions packages/rocketchat-api/server/v1/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { check } from 'meteor/check';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat } from 'meteor/rocketchat:lib';
import { PhoneNumberUtil } from 'google-libphonenumber';
import * as Mailer from 'meteor/rocketchat:mailer';


const phoneUtil = PhoneNumberUtil.getInstance();

Expand Down Expand Up @@ -185,17 +187,16 @@ RocketChat.API.v1.addRoute('invite.email', { authRequired: true }, {
throw new Meteor.Error('error-email-param-not-provided', 'The required "email" param is required.');
}

Meteor.runAsUser(this.userId, () => Meteor.call('sendInvitationEmail', [this.bodyParams.email]));
return RocketChat.API.v1.success();
if (!Mailer.checkAddressFormat(this.bodyParams.email)) {
return RocketChat.API.v1.failure('Invalid email address');
}

// sendInvitationEmail always returns an empty list
/*
if(this.bodyParams.email in result){
const result = Meteor.runAsUser(this.userId, () => Meteor.call('sendInvitationEmail', [this.bodyParams.email]));
if (result.indexOf(this.bodyParams.email) >= 0) {
return RocketChat.API.v1.success();
}else{
} else {
return RocketChat.API.v1.failure('Email Invite Failed');
}
*/
},
});

Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-mailer/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const sendNoWrap = ({ to, from, subject, html, headers }) => {
return;
}
Meteor.defer(() => Email.send({ to, from, subject, html, headers }));
return true;
};

export const send = ({ to, from, subject, html, data, headers }) => sendNoWrap({ to, from, subject: replace(subject, data), html: wrap(html, data), headers });
Expand Down

0 comments on commit 950f577

Please sign in to comment.