Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Do not send sent events to the server for multipart messages with invalid ID
Acho Arnoldf33312057264
diff --git a/api/pkg/handlers/message_handler.go b/api/pkg/handlers/message_handler.goindex b363863d..e85dfd65 100644--- a/api/pkg/handlers/message_handler.go+++ b/api/pkg/handlers/message_handler.go@@ -296,6 +296,7 @@ func (h *MessageHandler) PostEvent(c *fiber.Ctx) error {return h.responseUnprocessableEntity(c, errors, "validation errors while storing event")}+ request.Sanitize()message, err := h.service.GetMessage(ctx, h.userIDFomContext(c), uuid.MustParse(request.MessageID))if err != nil && stacktrace.GetCode(err) == repositories.ErrCodeNotFound {return h.responseNotFound(c, fmt.Sprintf("cannot find message with ID [%s]", request.MessageID))diff --git a/api/pkg/requests/message_event_request.go b/api/pkg/requests/message_event_request.goindex 156dd6c6..567cb436 100644--- a/api/pkg/requests/message_event_request.go+++ b/api/pkg/requests/message_event_request.go@@ -11,6 +11,8 @@ import (// MessageEvent is the payload for sending and SMS messagetype MessageEvent struct {+ request+// Timestamp is the time when the event was emitted, Please send the timestamp in UTC with as much precision as possibleTimestamp time.Time `json:"timestamp" example:"2022-06-05T14:26:09.527976+03:00"`@@ -26,8 +28,14 @@ type MessageEvent struct {MessageID string `json:"messageID" swaggerignore:"true"` // used internally for validation}+// Sanitize the message event+func (input *MessageEvent) Sanitize() *MessageEvent {+ input.MessageID = input.sanitizeMessageID(input.MessageID)+ return input+}+// ToMessageStoreEventParams converts MessageEvent to services.MessageStoreEventParams-func (input MessageEvent) ToMessageStoreEventParams(source string) services.MessageStoreEventParams {+func (input *MessageEvent) ToMessageStoreEventParams(source string) services.MessageStoreEventParams {return services.MessageStoreEventParams{MessageID: uuid.MustParse(input.MessageID),Source: source,diff --git a/api/pkg/requests/request.go b/api/pkg/requests/request.goindex b6842804..8b244cc3 100644--- a/api/pkg/requests/request.go+++ b/api/pkg/requests/request.go@@ -77,6 +77,17 @@ func (input *request) removeStringDuplicates(values []string) []string {return result}+func (input *request) sanitizeMessageID(value string) string {+ id := strings.Builder{}+ for _, char := range value {+ if char == '.' {+ return id.String()+ }+ id.WriteRune(char)+ }+ return id.String()+}+// getLimit gets the take as a stringfunc (input *request) getBool(value string) bool {if value == "true" {