Compare commits

...
Sign in to create a new pull request.

4 commits

4 changed files with 42 additions and 1 deletions

View file

@ -193,7 +193,8 @@ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
DEFAULT_FROM_EMAIL = "newsreader@rss.fudiggity.nl"
# Email
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# Project settings
VERSION = get_current_version()

View file

@ -45,6 +45,19 @@ TEMPLATES = [
}
]
# Email
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_DEFAULT_FROM", "webmaster@localhost")
EMAIL_HOST = os.environ.get("EMAIL_HOST", "localhost")
EMAIL_PORT = os.environ.get("EMAIL_PORT", 25)
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER", "")
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD", "")
EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS", False)
EMAIL_USE_SSL = os.environ.get("EMAIL_USE_SSL", False)
# Reddit integration
REDDIT_CLIENT_ID = os.environ.get("REDDIT_CLIENT_ID", "")
REDDIT_CLIENT_SECRET = os.environ.get("REDDIT_CLIENT_SECRET", "")

View file

@ -1,5 +1,7 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import send_mail
from django.utils.translation import ugettext as _
import requests
@ -106,6 +108,16 @@ class RedditTokenTask(app.Task):
user.reddit_refresh_token = None
user.save()
message = _(
"Your Reddit account credentials have expired. Re-authenticate in"
" the settings page to keep retrieving Reddit specific information"
" from your account."
)
send_mail(
"Reddit account needs re-authentication", message, None, [user.email]
)
return
response_data = response.json()

View file

@ -5,8 +5,10 @@ from datetime import datetime
from json import JSONDecodeError
from django.conf import settings
from django.core.mail import send_mail
from django.utils import timezone
from django.utils.html import format_html, urlize
from django.utils.translation import ugettext as _
import pytz
@ -240,6 +242,19 @@ class TwitterClient(PostClient):
stream.rule.user.twitter_oauth_token_secret = None
stream.rule.user.save()
message = _(
"Your Twitter account credentials have expired. Re-authenticate in"
" the settings page to keep retrieving Twitter specific information"
" from your account."
)
send_mail(
"Twitter account needs re-authentication",
message,
None,
[stream.rule.user.email],
)
self.set_rule_error(stream.rule, e)
break