Skip to content

Commit

Permalink
feat: fix template code in Amazon SNS client
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Dec 21, 2023
1 parent e8925b6 commit 9195708
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ func GetAmazonSNSClient(accessKeyID string, secretAccessKey string, template str
}

func (a *AmazonSNSClient) SendMessage(param map[string]string, targetPhoneNumber ...string) error {
code, ok := param["code"]
if !ok {
return fmt.Errorf("missing parameter: code")
}

bodyContent := fmt.Sprintf(a.template, code)

if len(targetPhoneNumber) < 1 {
return fmt.Errorf("missing parameter: targetPhoneNumber")
}
Expand All @@ -67,7 +74,7 @@ func (a *AmazonSNSClient) SendMessage(param map[string]string, targetPhoneNumber

for i := 0; i < len(targetPhoneNumber); i++ {
_, err := a.svc.Publish(&sns.PublishInput{
Message: &a.template,
Message: &bodyContent,
PhoneNumber: &targetPhoneNumber[i],
MessageAttributes: messageAttributes,
})
Expand Down

0 comments on commit 9195708

Please sign in to comment.