-
Notifications
You must be signed in to change notification settings - Fork 2.2k
refactor: create verifySMTPEmailSettings GraphQL mutation, replace meteor version #5531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: create verifySMTPEmailSettings GraphQL mutation, replace meteor version #5531
Conversation
Signed-off-by: Erik Kieckhafer <[email protected]>
… this method Signed-off-by: Erik Kieckhafer <[email protected]>
…r-removeContextInGraphQL-verifySMTPEmailSettings
…r-removeContextInGraphQL-verifySMTPEmailSettings
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
|
Edit: Nevermind, figured out the issue. |
Signed-off-by: Erik Kieckhafer <[email protected]>
aldeed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, and if possible it would be good to add one Jest integration test for the new mutation. I think if you maybe use nock you could simulate an SMTP server that would pass verification.
|
|
||
| const verified = await transporter.verify() | ||
| .then((result) => result) | ||
| .catch((error) => { throw new ReactionError(error.responseCode, error.response); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using async/await, it's best to stick with that and try/catch instead of also using .then and .catch.
let verified;
try {
verified = await transporter.verify();
} catch (error) {
throw new ReactionError(error.responseCode, error.response);
}
return verified;| clientMutationId: String | ||
|
|
||
| "Are the settings OK" | ||
| verified: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe do isVerified to follow the rule about boolean naming. It should be safe to do Boolean!, too. I don't think it will ever be null when there were no errors.
| "The same string you sent with the mutation params, for matching mutation calls with their responses" | ||
| clientMutationId: String | ||
|
|
||
| "Are the settings OK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More descriptive description would be "True if the SMTP connection was made and authentication was successful."
| cancelButtonText: i18next.t("app.cancel"), | ||
| confirmButtonColor: "#DD6B55", | ||
| confirmButtonText: i18next.t("app.save") | ||
| }).then(() => save()).catch(() => true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using async/await, it's best to stick with that and try/catch instead of also using .then and .catch.
let shouldSave = true;
try {
await client.mutate({
mutation: verifySMTPEmailSettings,
variables: {
input: {
host: settings.host,
password: settings.password,
port: settings.port,
service: settings.service,
shopId: opaqueShopId,
user: settings.user
}
}
});
} catch (error) {
shouldSave = false;
}
if (!shouldSave) {
try {
await Alert({
title: i18next.t("mail.alerts.connectionFailed"),
text: i18next.t("mail.alerts.saveAnyway"),
type: "warning",
showCancelButton: true,
cancelButtonText: i18next.t("app.cancel"),
confirmButtonColor: "#DD6B55",
confirmButtonText: i18next.t("app.save")
})
} catch (error) {
callback();
return;
}
}
callback();
await save();It's still a bit weird. If it doesn't work and what you have does work, then it's fine. We should eventually make a confirm Alert that returns true/false rather than throwing so we don't need so many try/catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was struggling with getting try/catch to work, and it just wasn't, which is why i'm doing the different then...catch in both places here. I'll try again with what you've posted here, but it was just being weird.
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
…EmailSettings' and 'refactor-kieckhafer-removeContextInGraphQL-verifySMTPEmailSettings' of github.com:/reactioncommerce/reaction into refactor-kieckhafer-removeContextInGraphQL-verifySMTPEmailSettings
Signed-off-by: Erik Kieckhafer <[email protected]>
aldeed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kieckhafer One more little thing.
imports/plugins/included/email-smtp/server/no-meteor/mutations/verifySMTPEmailSettings.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Erik Kieckhafer <[email protected]>
|
OK to merge, but holding off until integration test is added. |
Signed-off-by: Erik Kieckhafer <[email protected]>
Resolves parts of #5529
Impact: minor
Type: feat|refactor
Issue
email/verifySettingswas a meteor method which usedgetGraphQLContextInMeteorMethodSolution
Rewrite the meteor method to be a
verifySMTPEmailSettingsGraphQL mutation, which in turn will remove usage ofgetGraphQLContextInMeteorMethod.The color of the status indicator is not reactive. This is not a regression, it is currently not reactive in
master. Since there are other Meteor methods and more refactors of this code to come in the future, I've chosen to leave this as is for now.Breaking changes
Any custom code which used the
email/verifySettingsmeteor method will need to be updated to use the GraphQL mutationTesting