Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon SNS Subject support #797

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ssennettau
Copy link

Description:

Related issue (if applicable): n/a

Added support for Amazon SNS to handle Subjects as titles where the target is an SNS Topic, rather than phone number for an SMS message.

Increased the title_maxlen to the limit for the Amazon SNS where used for topics. Extended the logic to ensure backwards compatibility, so that the title is still added to the SMS messages, and retained in the body of messages sent to a Topic as well. Newer versions will still produce the same as the original output, with the sole exception being that the title will be used as the Subject for any email endpoints in topics. SMS endpoints within topics also behave as expected, with no change.

Minor update to AWS_HTTP_ERROR_MAP to cover insufficient IAM permissions, specifically that sns:CreateTopic is also needed along with sns:Publish

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@sns-subject-support

# Test out the changes with the following commands:

# 1. SNS Topic - Title and Body
./bin/apprise -vv -t "Testing the Title" -b "Body Test" sns://AccessKeyID/AccessSecretKey/RegionName/Topic

# 2. SMS Message - Title and Body
./bin/apprise -vv -t "Testing the Title" -b "Body Test" sns://AccessKeyID/AccessSecretKey/RegionName/+PhoneNo

# 3. SNS Topic - Body Only
./bin/apprise -vv -b "Body Test" sns://AccessKeyID/AccessSecretKey/RegionName/Topic

# 4. SMS Message - Body Only
./bin/apprise -vv -b "Body Test" sns://AccessKeyID/AccessSecretKey/RegionName/+PhoneNo

# 5. Error message - Should fail and proceduce error using ineffective access key
./bin/apprise -vv -b "Body Test" sns://AKIA0000000000000000/A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0/us-east-1/doesntexisttopic

@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2022

Codecov Report

Base: 100.00% // Head: 99.98% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (c4cb97f) compared to base (3d07004).
Patch coverage: 66.66% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##            master     #797      +/-   ##
===========================================
- Coverage   100.00%   99.98%   -0.02%     
===========================================
  Files          116      116              
  Lines        14935    14940       +5     
  Branches      3056     3058       +2     
===========================================
+ Hits         14935    14938       +3     
- Misses           0        1       +1     
- Partials         0        1       +1     
Impacted Files Coverage Δ
apprise/plugins/NotifySNS.py 98.95% <66.66%> (-1.05%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@caronc
Copy link
Owner

caronc commented Dec 31, 2022

Just a few quick fixes and add 1 or 2 URLs to test the new edge cases to fix missing code coverage and this is a wrap. Thank you for your contribution 🚀🚀. Happy New Year too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants