Sending contact us email and details in discord channel#359
Conversation
Reviewer's Guide by SourceryThis pull request implements a new feature for sending contact us emails and posting details to a Discord channel. The changes include adding a new gRPC method for sending contact us emails, creating a new endpoint for handling contact us submissions, and updating the necessary infrastructure to support these features. File-Level Changes
Tips
|
There was a problem hiding this comment.
Hey @nxtcoder19 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟡 Security: 1 issue found
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
| Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` | ||
| CompanyName string `protobuf:"bytes,3,opt,name=companyName,proto3" json:"companyName,omitempty"` | ||
| Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"` | ||
| MobileNumber int64 `protobuf:"varint,5,opt,name=mobileNumber,proto3" json:"mobileNumber,omitempty"` |
There was a problem hiding this comment.
suggestion: Consider using string for MobileNumber
Phone numbers often contain non-digit characters and may have leading zeros. Using a string type would be more flexible and avoid potential issues with international numbers or formatting.
MobileNumber string `protobuf:"bytes,5,opt,name=mobileNumber,proto3" json:"mobileNumber,omitempty"`
| return c.SendString("OK") | ||
| }) | ||
|
|
||
| app.Post("/contact-us", func(ctx *fiber.Ctx) error { |
There was a problem hiding this comment.
🚨 suggestion (security): Implement rate limiting and CAPTCHA for contact form
To prevent abuse and spam, consider adding rate limiting and a CAPTCHA mechanism to the contact form endpoint.
app.Post("/contact-us", limiter.New(limiter.Config{
Max: 5,
Expiration: 1 * time.Minute,
}), middleware.Captcha(), func(ctx *fiber.Ctx) error {
| app.Post("/contact-us", func(ctx *fiber.Ctx) error { | ||
| var data *domain.ContactUsData | ||
|
|
||
| if err := ctx.BodyParser(&data); err != nil { |
There was a problem hiding this comment.
suggestion: Improve error handling specificity
Instead of returning generic error messages, consider providing more specific error responses for different types of failures. This will help with debugging and improve the API's usability.
if err := ctx.BodyParser(&data); err != nil {
var errMsg string
switch {
case errors.Is(err, fiber.ErrUnprocessableEntity):
errMsg = "Invalid data format"
case errors.Is(err, fiber.ErrRequestEntityTooLarge):
errMsg = "Request payload too large"
default:
errMsg = "Error parsing request body"
}
return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": errMsg})
}
| NatsURL string `env:"NATS_URL" required:"false"` | ||
|
|
||
| CommsService string `env:"COMMS_SERVICE" required:"true"` | ||
| DiscordWebhookUrl string `env:"DISCORD_WEBHOOK_URL" required:"false"` |
There was a problem hiding this comment.
suggestion: Document the purpose of DiscordWebhookUrl
Add a comment explaining the purpose and usage of the DiscordWebhookUrl environment variable for better maintainability and easier configuration.
| DiscordWebhookUrl string `env:"DISCORD_WEBHOOK_URL" required:"false"` | |
| // DiscordWebhookUrl is the URL for sending notifications to a Discord channel. | |
| // If set, it enables Discord integration for important system alerts. | |
| DiscordWebhookUrl string `env:"DISCORD_WEBHOOK_URL" required:"false"` |
653c5a3 to
ebd6b6d
Compare
Resolves kloudlite/internal-workflows#10
Summary by Sourcery
Implement a new feature to handle 'Contact Us' form submissions by sending emails and posting details to a Discord channel. This includes adding a new gRPC method, HTTP endpoint, and email template.
New Features:
Enhancements:
Build: