-
Notifications
You must be signed in to change notification settings - Fork 2.2k
chore: clean-up tasks related to removing appEvents from all meteor code
#5692
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
chore: clean-up tasks related to removing appEvents from all meteor code
#5692
Conversation
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
…r-movePackageToNodeApp-cleanupTasks-appEvents
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
…eor methods Signed-off-by: Erik Kieckhafer <[email protected]>
…thods Signed-off-by: Erik Kieckhafer <[email protected]>
|
@aldeed The following Meteor methods have been removed or refactored to no longer use I believe this only leaves I think either way, this can be reviewed / merged to incorporate all the other changes, and we can handle |
Signed-off-by: Erik Kieckhafer <[email protected]>
| // Should it be `discounts`, or `cart`? | ||
| if (!userHasPermission(["owner", "admin", "discounts"], shopId)) { | ||
| throw new ReactionError("access-denied", "Access Denied"); | ||
| } |
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.
Since discounts is more for defining/editing discounts, I'd create a new role discounts/apply for here.
| // How do we determine this check if the user is the cart owner? | ||
| if (!userHasPermission(["admin", "owner", "discounts"], shopId)) { | ||
| throw new ReactionError("access-denied", "Access Denied"); | ||
| } |
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.
This one seems unnecessary given that getCart will already limit to carts that belong to the account/token, and then you have a separate admin check below it.
|
|
||
| if (participatingShops.length > 1) { | ||
| throw new ReactionError("not-implemented", "discounts.multiShopError", "Discounts cannot be applied to a multi-shop cart or order"); | ||
| } |
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.
Nothing from line 63 down to here is necessary. Carts can no longer contain items from multiple shops.
|
|
||
| // validate basic limit handling | ||
| if (accountLimitExceeded === true || discountLimitExceeded === true) { | ||
| return { i18nKeyLabel: "Code is expired", i18nKey: "discounts.codeIsExpired" }; |
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'd prefer to throw a ReactionError and let the client translate the error to the i18n key.
| // How do we determine this check if the user is the cart owner? | ||
| if (!userHasPermission(["admin", "owner", "discounts"], shopId)) { | ||
| throw new ReactionError("access-denied", "Access Denied"); | ||
| } |
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.
Same comment as other file. This check doesn't seem necessary, and the later check can use a new discounts/apply. Doesn't seem necessary to have a separate discounts/remove role. If you can apply, you should be able to remove, right?
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 think that makes sense. Will keep discounts/apply
| // Should it be `discounts`, or `cart`? | ||
| if (!userHasPermission(["owner", "admin", "discounts"], shopId)) { | ||
| throw new ReactionError("access-denied", "Access Denied"); | ||
| } |
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.
Since you already have shopId, you can move this permission check above the Cart.findOne, but be sure to pass shopId into the findOne query.
| // object from the existing cart, then pass to `saveCart` | ||
| // to re-run cart through all transforms and validations. | ||
| const updatedCartBilling = cart.billing.filter((doc) => doc._id !== discountCodeId); | ||
| cart.billing = updatedCartBilling; |
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.
You could add a check for whether cart.billing.length and updatedCartBilling.length are the same. If so, the discount code ID was invalid so throw an error.
|
|
||
| const updatedCartWithRemovedDiscountCode = await context.mutations.removeDiscountCodeFromCart(context, { | ||
| cartId: decodeCartOpaqueId(cartId), | ||
| discountCodeId: decodePaymentOpaqueId(discountCodeId), |
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.
Even though we treat these as payments in the database, I'd make a separate namespace for it (reaction/discountCode) to keep it future-proof.
Signed-off-by: Erik Kieckhafer <[email protected]>
|
@aldeed comments addressed. |
and rename discountCodeId to discountId Signed-off-by: Eric Dobbertin <[email protected]>
Resolves #5691
Impact: minor
Type: feature|style|refactor|chore
Remove or refactor all code that calls
appEventsfrom meteor code.Refactored into mutations
discounts/codes/applydiscounts/codes/removeRemoved
updateShipmentStatusI don't believe this function is called anywhere in the app - it doesn't even seem to be attached to a meteor method anymore - so we can mostly likely just delete this fileworkflow/pushItemWorkflowWe want to removecoreItemWorkflowanyway, maybe this is the time? In addition, this is called from thecheckoutplugin, which I don't believe we don't use anymore, so maybe we remove this plugin?TODO
shop/createShopI don't believe this is used anymore, we can most likely just delete this function, along with the BlazeTemplatewhere it's being called.Testing
GraphiQLor another GQL interface to perform the actionA discount code is a payment, so the discount code id should be encoded with
reaction/payment