Commit b22404e9fb68c51bfa5047bb3a35ac03a361921a
1 parent
b7afd799
Change AWS SMS type from Promotional to Transactional
Showing
1 changed file
with
13 additions
and
0 deletions
@@ -20,6 +20,7 @@ import com.amazonaws.auth.AWSStaticCredentialsProvider; | @@ -20,6 +20,7 @@ import com.amazonaws.auth.AWSStaticCredentialsProvider; | ||
20 | import com.amazonaws.auth.BasicAWSCredentials; | 20 | import com.amazonaws.auth.BasicAWSCredentials; |
21 | import com.amazonaws.services.sns.AmazonSNS; | 21 | import com.amazonaws.services.sns.AmazonSNS; |
22 | import com.amazonaws.services.sns.AmazonSNSClient; | 22 | import com.amazonaws.services.sns.AmazonSNSClient; |
23 | +import com.amazonaws.services.sns.model.MessageAttributeValue; | ||
23 | import com.amazonaws.services.sns.model.PublishRequest; | 24 | import com.amazonaws.services.sns.model.PublishRequest; |
24 | import lombok.extern.slf4j.Slf4j; | 25 | import lombok.extern.slf4j.Slf4j; |
25 | import org.apache.commons.lang3.StringUtils; | 26 | import org.apache.commons.lang3.StringUtils; |
@@ -28,9 +29,20 @@ import org.thingsboard.rule.engine.api.sms.exception.SmsException; | @@ -28,9 +29,20 @@ import org.thingsboard.rule.engine.api.sms.exception.SmsException; | ||
28 | import org.thingsboard.rule.engine.api.sms.exception.SmsSendException; | 29 | import org.thingsboard.rule.engine.api.sms.exception.SmsSendException; |
29 | import org.thingsboard.server.service.sms.AbstractSmsSender; | 30 | import org.thingsboard.server.service.sms.AbstractSmsSender; |
30 | 31 | ||
32 | +import java.util.HashMap; | ||
33 | +import java.util.Map; | ||
34 | + | ||
31 | @Slf4j | 35 | @Slf4j |
32 | public class AwsSmsSender extends AbstractSmsSender { | 36 | public class AwsSmsSender extends AbstractSmsSender { |
33 | 37 | ||
38 | + private static final Map<String, MessageAttributeValue> SMS_ATTRIBUTES = new HashMap<>(); | ||
39 | + | ||
40 | + static { | ||
41 | + SMS_ATTRIBUTES.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue() | ||
42 | + .withStringValue("Transactional") | ||
43 | + .withDataType("String")); | ||
44 | + } | ||
45 | + | ||
34 | private AmazonSNS snsClient; | 46 | private AmazonSNS snsClient; |
35 | 47 | ||
36 | public AwsSmsSender(AwsSnsSmsProviderConfiguration config) { | 48 | public AwsSmsSender(AwsSnsSmsProviderConfiguration config) { |
@@ -51,6 +63,7 @@ public class AwsSmsSender extends AbstractSmsSender { | @@ -51,6 +63,7 @@ public class AwsSmsSender extends AbstractSmsSender { | ||
51 | message = this.prepareMessage(message); | 63 | message = this.prepareMessage(message); |
52 | try { | 64 | try { |
53 | PublishRequest publishRequest = new PublishRequest() | 65 | PublishRequest publishRequest = new PublishRequest() |
66 | + .withMessageAttributes(SMS_ATTRIBUTES) | ||
54 | .withPhoneNumber(numberTo) | 67 | .withPhoneNumber(numberTo) |
55 | .withMessage(message); | 68 | .withMessage(message); |
56 | this.snsClient.publish(publishRequest); | 69 | this.snsClient.publish(publishRequest); |