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 | 20 | import com.amazonaws.auth.BasicAWSCredentials; |
21 | 21 | import com.amazonaws.services.sns.AmazonSNS; |
22 | 22 | import com.amazonaws.services.sns.AmazonSNSClient; |
23 | +import com.amazonaws.services.sns.model.MessageAttributeValue; | |
23 | 24 | import com.amazonaws.services.sns.model.PublishRequest; |
24 | 25 | import lombok.extern.slf4j.Slf4j; |
25 | 26 | import org.apache.commons.lang3.StringUtils; |
... | ... | @@ -28,9 +29,20 @@ import org.thingsboard.rule.engine.api.sms.exception.SmsException; |
28 | 29 | import org.thingsboard.rule.engine.api.sms.exception.SmsSendException; |
29 | 30 | import org.thingsboard.server.service.sms.AbstractSmsSender; |
30 | 31 | |
32 | +import java.util.HashMap; | |
33 | +import java.util.Map; | |
34 | + | |
31 | 35 | @Slf4j |
32 | 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 | 46 | private AmazonSNS snsClient; |
35 | 47 | |
36 | 48 | public AwsSmsSender(AwsSnsSmsProviderConfiguration config) { |
... | ... | @@ -51,6 +63,7 @@ public class AwsSmsSender extends AbstractSmsSender { |
51 | 63 | message = this.prepareMessage(message); |
52 | 64 | try { |
53 | 65 | PublishRequest publishRequest = new PublishRequest() |
66 | + .withMessageAttributes(SMS_ATTRIBUTES) | |
54 | 67 | .withPhoneNumber(numberTo) |
55 | 68 | .withMessage(message); |
56 | 69 | this.snsClient.publish(publishRequest); | ... | ... |