diff --git a/src/newsreader/news/collection/tasks.py b/src/newsreader/news/collection/tasks.py index 9ca65f9..799a101 100644 --- a/src/newsreader/news/collection/tasks.py +++ b/src/newsreader/news/collection/tasks.py @@ -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 @@ -107,7 +109,15 @@ class RedditTokenTask(app.Task): user.reddit_refresh_token = None user.save() - # TODO add notification mail + 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() diff --git a/src/newsreader/news/collection/twitter.py b/src/newsreader/news/collection/twitter.py index debe31e..c854e49 100644 --- a/src/newsreader/news/collection/twitter.py +++ b/src/newsreader/news/collection/twitter.py @@ -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,7 +242,18 @@ class TwitterClient(PostClient): stream.rule.user.twitter_oauth_token_secret = None stream.rule.user.save() - # TODO add notification mail + 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)