Skip to content

Commit

Permalink
fix send message
Browse files Browse the repository at this point in the history
  • Loading branch information
goddenrich committed Aug 28, 2024
1 parent 93af1b3 commit 6de0ddd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/gosqs/send_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func SendMessageV1(req *http.Request) (int, interfaces.AbstractResponseBody) {
log.Debugf("Putting Message in Queue: [%s]", queueName)
msg := app.Message{MessageBody: []byte(messageBody)}
if len(messageAttributes) > 0 {
oldStyleMessageAttributes := utils.ConvertToOldMessageAttributeValueStructure(messageAttributes)
oldStyleMessageAttributes := requestBody.GetMessageAttributes()
msg.MessageAttributes = oldStyleMessageAttributes
msg.MD5OfMessageAttributes = common.HashAttributes(oldStyleMessageAttributes)
}
Expand Down
2 changes: 1 addition & 1 deletion app/gosqs/send_message_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func SendMessageBatchV1(req *http.Request) (int, interfaces.AbstractResponseBody
for _, sendEntry := range sendEntries {
msg := app.Message{MessageBody: []byte(sendEntry.MessageBody)}
if len(sendEntry.MessageAttributes) > 0 {
oldStyleMessageAttributes := utils.ConvertToOldMessageAttributeValueStructure(sendEntry.MessageAttributes)
oldStyleMessageAttributes := sendEntry.GetMessageAttributes()
msg.MessageAttributes = oldStyleMessageAttributes
msg.MD5OfMessageAttributes = common.HashAttributes(oldStyleMessageAttributes)
}
Expand Down
8 changes: 8 additions & 0 deletions app/models/sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ type SendMessageRequest struct {
QueueUrl string `json:"QueueUrl" schema:"QueueUrl"`
}

func (r *SendMessageRequest) GetMessageAttributes() map[string]app.MessageAttributeValue {
return convertToOldMessageAttributeValueStructure(r.MessageAttributes)
}

func (r *SendMessageRequest) SetAttributesFromForm(values url.Values) {
for i := 1; true; i++ {
nameKey := fmt.Sprintf("MessageAttribute.%d.Name", i)
Expand Down Expand Up @@ -282,6 +286,10 @@ type SendMessageBatchRequestEntry struct {
MessageSystemAttributes map[string]MessageAttributeValue `json:"MessageSystemAttributes" schema:"MessageSystemAttributes"` // NOTE: not implemented
}

func (e *SendMessageBatchRequestEntry) GetMessageAttributes() map[string]app.MessageAttributeValue {
return convertToOldMessageAttributeValueStructure(e.MessageAttributes)
}

// Get Queue Url Request
func NewGetQueueUrlRequest() *GetQueueUrlRequest {
return &GetQueueUrlRequest{}
Expand Down

0 comments on commit 6de0ddd

Please sign in to comment.