-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: add a resend email route for organizers #6163
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
feat: add a resend email route for organizers #6163
Conversation
32b8d44 to
d71c128
Compare
|
@mrsaicharan1 @prateekj117 @shreyanshdwivedi Please review |
Codecov Report
@@ Coverage Diff @@
## development #6163 +/- ##
===============================================
- Coverage 66.18% 66.08% -0.11%
===============================================
Files 288 288
Lines 14460 14497 +37
===============================================
+ Hits 9571 9580 +9
- Misses 4889 4917 +28
Continue to review full report at Codecov.
|
app/api/orders.py
Outdated
| return redirect(make_frontend_url('orders/{}/view'.format(order_identifier))) | ||
|
|
||
|
|
||
| @order_misc_routes.route('/orders/<string:order_identifier>/resend-email', methods=['POST']) |
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.
Ensure this endpoint has rate limiting
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.
Done!
app/api/orders.py
Outdated
| :param order_identifier: | ||
| :return: JSON response if the email was succesfully sent | ||
| """ | ||
| order = safe_query(db, Order, 'identifier', order_identifier, 'identifier') |
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.
Sometimes, the order may not be fetched. So I guess a try...except block would be great here :D
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.
The failure is simply handled by a server 500 in the safe_query itself, IMO that should do
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.
Check this too!
86d3eb8 to
71c510a
Compare
app/api/auth.py
Outdated
| '3/hour', key_func=lambda: request.json['data']['order'], error_message='Limit for this action exceeded' | ||
| ) | ||
| @limiter.limit( | ||
| '1/minute', key_func=get_remote_address, error_message='Limit for this action exceeded' |
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.
IMO 1/minute is very less for this threshold. An organizer can go on clicking the resent invite button on the client side so we should increase this. @iamareebjamal what can be a suitable threshold for this endpoint?
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 3/minute ? @shreyanshdwivedi @iamareebjamal
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.
60/minute for IP
5/minute for user_id
| invoice_path = 'generated/invoices/{}/{}/'.format(key, generate_hash(key)) + order_identifier + '.pdf' | ||
|
|
||
| # send email. | ||
| send_email_to_attendees(order=order, purchaser_id=current_user.id, attachments=[ticket_path, invoice_path]) |
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 believe that attachments should be empty for placed orders as they're meant for offline tickets?
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 placed orders should have tickets too. They are meant to show this ticket when they reach event venue
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 placed orders should have tickets too. They are meant to show this ticket when they reach event venue
Agreed 👍
89dbaea to
639a187
Compare
app/api/auth.py
Outdated
| return jsonify(status=True, message="Verification emails for order : {} has been sent succesfully". | ||
| format(order_identifier)) | ||
| else: | ||
| return jsonify(status=False, message="Only placed and complete orders are verified") |
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 be raised as an error. Not a success 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.
@niranjan94 did it, please check.
app/api/auth.py
Outdated
|
|
||
| @ticket_blueprint.route('/orders/resend-email', methods=['POST']) | ||
| @limiter.limit( | ||
| '5/minute', key_func=lambda: request.json['data']['order'], error_message='Limit for this action exceeded' |
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.
Where is limit by user?
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.
@iamareebjamal modified order to user key.
|
Did you test it? |
|
@iamareebjamal yes, tested it via postman, it's working as expected. |
|
@mrsaicharan1 @shreyanshdwivedi @prateekj117 Please review |
| return jsonify(status=True, message="Verification emails for order : {} has been sent succesfully". | ||
| format(order_identifier)) | ||
| else: | ||
| return UnprocessableEntityError({'source': 'data/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.
Why is it returning instead of raising?
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.
@iamareebjamal because these errors are actually a subclass of ErrorResponse and not actual errors. To make them work we need to initiate their respond function (the same error classes have been used all through this file)
| return UnprocessableEntityError({'source': 'data/order'}, | ||
| "Only placed and completed orders have confirmation").respond() | ||
| else: | ||
| return ForbiddenError({'source': ''}, "Co-Organizer Access Required").respond() |
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
* add the resend email route * resend emails using ticket route * handle errors with UnprocessableEntry * modify order to user key
Fixes #6162
Short description of what this resolves:
This adds an endpoint which triggers re sending email confirmation for tickets
Changes proposed in this pull request:
Checklist
developmentbranch.