Implement basic SNS message filtering (#1521)
* Add support for FilterPolicy to sns subscription set_filter_attributes * Add basic support for sns message filtering This adds support for exact string value matching along with AND/OR logic as described here: https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html It does not provide support for: - Anything-but string matching - Prefix string matching - Numeric Value Matching The above filter policies (if configured) will not match messages.
This commit is contained in:
parent
6dce7dcb18
commit
d3d9557d49
5 changed files with 194 additions and 8 deletions
|
|
@ -241,6 +241,10 @@ class SNSResponse(BaseResponse):
|
|||
phone_number = self._get_param('PhoneNumber')
|
||||
subject = self._get_param('Subject')
|
||||
|
||||
message_attributes = self._get_map_prefix('MessageAttributes.entry',
|
||||
key_end='Name',
|
||||
value_end='Value')
|
||||
|
||||
if phone_number is not None:
|
||||
# Check phone is correct syntax (e164)
|
||||
if not is_e164(phone_number):
|
||||
|
|
@ -265,7 +269,9 @@ class SNSResponse(BaseResponse):
|
|||
message = self._get_param('Message')
|
||||
|
||||
try:
|
||||
message_id = self.backend.publish(arn, message, subject=subject)
|
||||
message_id = self.backend.publish(
|
||||
arn, message, subject=subject,
|
||||
message_attributes=message_attributes)
|
||||
except ValueError as err:
|
||||
error_response = self._error('InvalidParameter', str(err))
|
||||
return error_response, dict(status=400)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue