Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from flask_restx import Resource, reqparse
  2. from controllers.console.wraps import setup_required
  3. from controllers.inner_api import inner_api_ns
  4. from controllers.inner_api.wraps import billing_inner_api_only, enterprise_inner_api_only
  5. from tasks.mail_inner_task import send_inner_email_task
  6. _mail_parser = reqparse.RequestParser()
  7. _mail_parser.add_argument("to", type=str, action="append", required=True)
  8. _mail_parser.add_argument("subject", type=str, required=True)
  9. _mail_parser.add_argument("body", type=str, required=True)
  10. _mail_parser.add_argument("substitutions", type=dict, required=False)
  11. class BaseMail(Resource):
  12. """Shared logic for sending an inner email."""
  13. def post(self):
  14. args = _mail_parser.parse_args()
  15. send_inner_email_task.delay(
  16. to=args["to"],
  17. subject=args["subject"],
  18. body=args["body"],
  19. substitutions=args["substitutions"],
  20. )
  21. return {"message": "success"}, 200
  22. @inner_api_ns.route("/enterprise/mail")
  23. class EnterpriseMail(BaseMail):
  24. method_decorators = [setup_required, enterprise_inner_api_only]
  25. @inner_api_ns.doc("send_enterprise_mail")
  26. @inner_api_ns.doc(description="Send internal email for enterprise features")
  27. @inner_api_ns.expect(_mail_parser)
  28. @inner_api_ns.doc(
  29. responses={200: "Email sent successfully", 401: "Unauthorized - invalid API key", 404: "Service not available"}
  30. )
  31. def post(self):
  32. """Send internal email for enterprise features.
  33. This endpoint allows sending internal emails for enterprise-specific
  34. notifications and communications.
  35. Returns:
  36. dict: Success message with status code 200
  37. """
  38. return super().post()
  39. @inner_api_ns.route("/billing/mail")
  40. class BillingMail(BaseMail):
  41. method_decorators = [setup_required, billing_inner_api_only]
  42. @inner_api_ns.doc("send_billing_mail")
  43. @inner_api_ns.doc(description="Send internal email for billing notifications")
  44. @inner_api_ns.expect(_mail_parser)
  45. @inner_api_ns.doc(
  46. responses={200: "Email sent successfully", 401: "Unauthorized - invalid API key", 404: "Service not available"}
  47. )
  48. def post(self):
  49. """Send internal email for billing notifications.
  50. This endpoint allows sending internal emails for billing-related
  51. notifications and alerts.
  52. Returns:
  53. dict: Success message with status code 200
  54. """
  55. return super().post()