diff --git a/env b/env index b00bed215..32b95bb8f 100644 --- a/env +++ b/env @@ -2,8 +2,8 @@ export FLASK_APP="/rDrama/files/cli:app" export SITE="localhost" export SITE_NAME="rDrama" export SECRET_KEY="blahblahblah" -export DATABASE_URL="postgresql://postgres@localhost:5432" -export REDIS_URL="redis://localhost:6379" +export DATABASE_URL="postgresql://postgres@postgres:5432" +export REDIS_URL="redis://redis:6379" export PROXY_URL="http://localhost:18080" export LOG_DIRECTORY="/var/log/rdrama" export SETTINGS_FILENAME="/site_settings.json" diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index 589b25f89..aca51924d 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -21,12 +21,14 @@ from files.helpers.sanitize import sanitize def offsite_mentions_task(cache:Cache): site_mentions = get_mentions(cache, const.REDDIT_NOTIFS_SITE) - notify_mentions(send_to, site_mentions) + notify_mentions(site_mentions) if const.REDDIT_NOTIFS_USERS: for query, send_user in const.REDDIT_NOTIFS_USERS.items(): user_mentions = get_mentions(cache, [query], reddit_notifs_users=True) - notify_mentions([send_user], user_mentions, mention_str='mention of you') + notify_mentions(user_mentions, send_to=send_user, mention_str='mention of you') + + g.db.commit() # commit early otherwise localhost testing fails to commit def get_mentions(cache:Cache, queries:Iterable[str], reddit_notifs_users=False): kinds = ['submission', 'comment'] @@ -79,7 +81,7 @@ def get_mentions(cache:Cache, queries:Iterable[str], reddit_notifs_users=False): print("Failed to set cache value; there may be duplication of reddit notifications") return mentions -def notify_mentions(send_to, mentions, mention_str='site mention'): +def notify_mentions(mentions, send_to=None, mention_str='site mention'): for m in mentions: author = m['author'] permalink = m['permalink'] @@ -108,7 +110,6 @@ def notify_mentions(send_to, mentions, mention_str='site mention'): g.db.flush() new_comment.top_comment_id = new_comment.id - if mention_str == 'mention of you': - for user_id in send_to: - notif = Notification(comment_id=new_comment.id, user_id=user_id) - g.db.add(notif) + if send_to: + notif = Notification(comment_id=new_comment.id, user_id=send_to) + g.db.add(notif)