-
Notifications
You must be signed in to change notification settings - Fork 0
Staging #16
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
Staging #16
Changes from all commits
a9f7548
bddb02e
24e02ed
08a7be9
9b310d9
7b13ea7
0c0354c
064d9db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ type queuedMessage struct { | |
| // @Param platform formData string false "Platform (multipart)" | ||
| // @Param text formData string false "Message text (multipart, optional if file provided)" | ||
| // @Param file formData file false "File to upload (multipart)" | ||
| // @Success 200 {object} SendMessageResponse "Message queued successfully" | ||
| // @Success 200 {object} SendMessageResponse "Message(s) queued successfully" | ||
| // @Failure 400 {object} ErrorResponse "Invalid request body or validation error" | ||
| // @Failure 401 {object} ErrorResponse "Invalid or expired matrix token" | ||
| // @Failure 403 {object} ErrorResponse "Invalid or expired matrix token" | ||
|
|
@@ -159,23 +159,39 @@ func (h *DeviceHandler) SendMessage(c echo.Context) error { | |
| return echo.ErrInternalServerError | ||
| } | ||
|
|
||
| message := queuedMessage{ | ||
| DeviceID: deviceID, | ||
| Contact: req.Contact, | ||
| PlatformName: req.Platform, | ||
| Text: req.Text, | ||
| Username: matrixUsername, | ||
| FileContent: fileContent, | ||
| FileExtension: fileExtension, | ||
| addresses := strings.SplitSeq(req.Contact, ",") | ||
| validCount := 0 | ||
| for address := range addresses { | ||
| address = strings.TrimSpace(address) | ||
| if address == "" { | ||
| continue | ||
| } | ||
| validCount++ | ||
|
|
||
| message := queuedMessage{ | ||
| DeviceID: deviceID, | ||
| Contact: address, | ||
| PlatformName: req.Platform, | ||
| Text: req.Text, | ||
| Username: matrixUsername, | ||
| FileContent: fileContent, | ||
| FileExtension: fileExtension, | ||
| } | ||
|
|
||
| if err := producer.Publish(exchangeName, routingKey, message, rabbitmq.DefaultPublishOptions()); err != nil { | ||
| logger.Error(fmt.Sprintf("RabbitMQ message publish failed for address %s: %v\n%s", address, err, debug.Stack())) | ||
| return echo.ErrInternalServerError | ||
| } | ||
| } | ||
|
Comment on lines
+162
to
185
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot open an issue for this feedback tag as enhancement
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have the capability to create GitHub issues with my available tools. You can open the issue manually using the details below: Title: Enforce max-recipients limit on comma-separated contact field to prevent DoS Labels: Body:
|
||
|
|
||
| if err := producer.Publish(exchangeName, routingKey, message, rabbitmq.DefaultPublishOptions()); err != nil { | ||
| logger.Error(fmt.Sprintf("RabbitMQ message publish failed: %v\n%s", err, debug.Stack())) | ||
| return echo.ErrInternalServerError | ||
| if validCount == 0 { | ||
| return c.JSON(http.StatusBadRequest, map[string]string{ | ||
| "error": "Missing required field: contact", | ||
| }) | ||
| } | ||
|
|
||
| logger.Info("Message queued successfully") | ||
| logger.Info("Message(s) queued successfully") | ||
| return c.JSON(http.StatusOK, SendMessageResponse{ | ||
| Message: "Message queued successfully", | ||
| Message: "Message(s) queued successfully", | ||
| }) | ||
| } | ||
Large diffs are not rendered by default.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.