diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-02-26 15:18:51 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-02-26 15:18:51 +0100 |
commit | 7866813a4fffd60157626605d1e4cb1b1070214b (patch) | |
tree | 92efe39c8e6889d2caf3a615592a96d895c0f073 | |
parent | Removed Flask-SSLify and Heroku default support. (diff) | |
download | newspipe-7866813a4fffd60157626605d1e4cb1b1070214b.tar.gz newspipe-7866813a4fffd60157626605d1e4cb1b1070214b.tar.bz2 newspipe-7866813a4fffd60157626605d1e4cb1b1070214b.zip |
Removed sendgrid dependency.
-rw-r--r-- | newspipe/conf.py | 3 | ||||
-rw-r--r-- | newspipe/notifications/emails.py | 50 | ||||
-rw-r--r-- | poetry.lock | 29 | ||||
-rw-r--r-- | pyproject.toml | 1 |
4 files changed, 1 insertions, 82 deletions
diff --git a/newspipe/conf.py b/newspipe/conf.py index 96445b24..fcdaef75 100644 --- a/newspipe/conf.py +++ b/newspipe/conf.py @@ -27,7 +27,6 @@ DEFAULTS = {"platform_url": "https://www.newspipe.org/", "self_registration": "false", "cdn_address": "", "admin_email": "info@newspipe.org", - "sendgrid_api_key": "", "token_validity_period": "3600", "default_max_error": "3", "log_path": "newspipe.log", @@ -98,8 +97,6 @@ NOTIFICATION_TLS = config.getboolean('notification', 'tls') NOTIFICATION_SSL = config.getboolean('notification', 'ssl') NOTIFICATION_USERNAME = config.get('notification', 'username') NOTIFICATION_PASSWORD = config.get('notification', 'password') -SENDGRID_API_KEY = config.get('notification', 'sendgrid_api_key') -POSTMARK_API_KEY = '' CSRF_ENABLED = True # slow database query threshold (in seconds) diff --git a/newspipe/notifications/emails.py b/newspipe/notifications/emails.py index e1f2c272..90c87c93 100644 --- a/newspipe/notifications/emails.py +++ b/newspipe/notifications/emails.py @@ -24,9 +24,6 @@ import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -import sendgrid -from sendgrid.helpers.mail import * - import conf from web.decorators import async_maker @@ -79,50 +76,3 @@ def send_smtp(to="", bcc="", subject="", plaintext="", html=""): else: s.sendmail(conf.NOTIFICATION_EMAIL, msg['To'] + ", " + msg['BCC'], msg.as_string()) s.quit() - - -def send_postmark(to="", bcc="", subject="", plaintext=""): - """ - Send an email via Postmark. Used when the application is deployed on - Heroku. - Note: The Postmark team has chosen not to continue development of the - Heroku add-on as of June 30, 2017. Newspipe is now using SendGrid when - deployed on Heroku. - """ - from postmark import PMMail - try: - message = PMMail(api_key = conf.POSTMARK_API_KEY, - subject = subject, - sender = conf.NOTIFICATION_EMAIL, - text_body = plaintext) - message.to = to - if bcc != "": - message.bcc = bcc - message.send() - except Exception as e: - logger.exception('send_postmark raised:') - raise e - - -def send_sendgrid(to="", bcc="", subject="", plaintext=""): - """ - Send an email via SendGrid. Used when the application is deployed on - Heroku. - """ - sg = sendgrid.SendGridAPIClient(apikey=conf.SENDGRID_API_KEY) - - mail = Mail() - mail.from_email = Email(conf.NOTIFICATION_EMAIL) - mail.subject = subject - mail.add_content(Content('text/plain', plaintext)) - - personalization = Personalization() - personalization.add_to(Email(to)) - if bcc != "": - personalization.add_bcc(Email(bcc)) - mail.add_personalization(personalization) - - response = sg.client.mail.send.post(request_body=mail.get()) - # print(response.status_code) - # print(response.body) - # print(response.headers) diff --git a/poetry.lock b/poetry.lock index 83a8feba..2631e7ca 100644 --- a/poetry.lock +++ b/poetry.lock @@ -419,14 +419,6 @@ version = "1.0.4" [[package]] category = "main" -description = "HTTP REST client, simplified for Python" -name = "python-http-client" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "3.2.5" - -[[package]] -category = "main" description = "A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges." name = "python-mimeparse" optional = false @@ -472,17 +464,6 @@ requests = ">=1.2.0" [[package]] category = "main" -description = "Twilio SendGrid library for Python" -name = "sendgrid" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "6.1.2" - -[package.dependencies] -python-http-client = ">=3.2.1" - -[[package]] -category = "main" description = "Python 2 and 3 compatibility utilities" name = "six" optional = false @@ -578,7 +559,7 @@ idna = ">=2.0" multidict = ">=4.0" [metadata] -content-hash = "55d68271b42d43858eb45a17f1de68d89ed73cd5b72a497af0d64185b1c9ca1b" +content-hash = "e8b3a93859c566e8f72ce498eaee7d1ff257823c60e95e064700951dd55e880a" python-versions = "^3.8" [metadata.files] @@ -838,9 +819,6 @@ python-editor = [ {file = "python_editor-1.0.4-py3-none-any.whl", hash = "sha256:1bf6e860a8ad52a14c3ee1252d5dc25b2030618ed80c022598f00176adc8367d"}, {file = "python_editor-1.0.4-py3.5.egg", hash = "sha256:c3da2053dbab6b29c94e43c486ff67206eafbe7eb52dbec7390b5e2fb05aac77"}, ] -python-http-client = [ - {file = "python_http_client-3.2.5.tar.gz", hash = "sha256:10bfbc7ecd25e55215680ce2827b1a3bf4e06ba4a59758039d047d6104b6f169"}, -] python-mimeparse = [ {file = "python-mimeparse-1.6.0.tar.gz", hash = "sha256:76e4b03d700a641fd7761d3cd4fdbbdcd787eade1ebfac43f877016328334f78"}, {file = "python_mimeparse-1.6.0-py2.py3-none-any.whl", hash = "sha256:a295f03ff20341491bfe4717a39cd0a8cc9afad619ba44b77e86b0ab8a2b8282"}, @@ -856,11 +834,6 @@ requests = [ requests-futures = [ {file = "requests-futures-1.0.0.tar.gz", hash = "sha256:35547502bf1958044716a03a2f47092a89efe8f9789ab0c4c528d9c9c30bc148"}, ] -sendgrid = [ - {file = "sendgrid-6.1.2-py3-none-any.whl", hash = "sha256:e2b8bd90522f22a22d2557aee9cb77d0c372a8c4ca35e65d062b4ecaf0b9a4bd"}, - {file = "sendgrid-6.1.2-py3.6.egg", hash = "sha256:faa8105a36cc8a02be4f4bbe22816d1d1c8985bbc7cc9f8bb4195870d7cff7e5"}, - {file = "sendgrid-6.1.2.tar.gz", hash = "sha256:8112a3e2edd4cef208ed46335f058d2782397b395b96a472dcfd5e2618cf621b"}, -] six = [ {file = "six-1.14.0-py2.py3-none-any.whl", hash = "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"}, {file = "six-1.14.0.tar.gz", hash = "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"}, diff --git a/pyproject.toml b/pyproject.toml index bfc12cea..a21daf6b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,6 @@ Flask-Babel = "^1.0.0" Flask-Migrate = "^2.5.2" Flask-Script = "^2.0.6" WTForms = "^2.2.1" -sendgrid = "^6.1.2" python-dateutil = "^2.8.1" psycopg2-binary = "^2.8.4" |