Notifier

Overview

The notifier is used to send html or plain text digest emails of unread messages to Discussions followers.  See the Devops Notifier Context additional details.

Here you will find the code for the notifer.

There is a separate repository named edx-notifications. This repo is under development, but not actively being developed or used at this time by edx.org for forums notifications.

Testing

Follow these instructions for receiving digest emails

To manually test on Stage:

  • Follow instructions above to receive digests
  • Make a change in Discussions that would be sent through the digest
  • Notifications are scheduled to be sent every 5 minutes, so wait a bit.
  • Verify the following:
    • make sure you retrieve an email (i.e. checks scheduler is finding users and finding updates for digests)

    • make sure the html output looks good

    • if the text contains Markdown, it will come as-is (e.g. ** non bold test **)

    • make sure the text output looks good (in gmail, choose the dropdown next to email ("More" tooltip) and select "Message text garbled?")

Testing and Troubleshooting in Devstack

Run LMS (a dependency)

sudo su edxapp
paver devstack lms [--fast]

Run Forums

sudo su forum
ruby app.rb -p 18080

Test Notifier (change to-date to an appropriate future date)

sudo su notifier
/edx/app/notifier/virtualenvs/notifier/bin/python /edx/app/notifier/src/manage.py forums_digest --help
/edx/app/notifier/virtualenvs/notifier/bin/python /edx/app/notifier/src/manage.py forums_digest --to_datetime=2015-11-13 --show-html
 

Testing and Troubleshooting in a production like environment (sandboxes and up)

You'll want to have two users, one posts and follows the post, the other comments on the post, then you can run the --users=firstuserid command below to see what notifier would do. 

You'll want to set {{to_datetime}} to the current date + 1 day (this is important - the forums_digest management command defaults to only look back one from the the {{to_datetime}} variable in determining which threads/posts need to have digests created).

sudo su notifier
/edx/app/notifier/virtualenvs/notifier/bin/python /edx/app/notifier/src/manage.py forums_digest --help
/edx/app/notifier/virtualenvs/notifier/bin/python /edx/app/notifier/src/manage.py forums_digest --to_datetime=2015-11-13 --show-html
OR (to limit the search to a single user)
/edx/app/notifier/virtualenvs/notifier/bin/python /edx/app/notifier/src/manage.py forums_digest --to_datetime=2015-11-13 --show-html --users=12345
 


Deploying new code to Sandboxes (and up)

When you create a sandbox: https://tools-edx-jenkins.edx.org/job/Sandboxes/job/CreateSandbox/ you'll want to check the "notifier" box and set the "notifier_version" to your branch name.  Once the sandbox is created, you can do the things below to run migrations (if necessary), restart the notifier workers and scheduler, and run the management command to send a test digest.


cd /edx/app/notifier # may be different on stage
source notifier_env
source virtualenvs/notifier/bin/activate
cd src/
# make sure to apply migrations if they haven't been applied yet
sudo -E /edx/app/notifier/virtualenvs/notifier/bin/python manage.py migrate --fake-initial
# restart notifier workers and scheduler
/edx/bin/supervisorctl restart notifier-celery-workers
/edx/bin/supervisorctl restart notifier-scheduler
# run the forums_digest management command to see that an email will be properly rendered and sent
# use today + 1 day as the datetime, pick a user who should get a digest (requires manual clicking in app)
sudo -E /edx/app/notifier/virtualenvs/notifier/bin/python manage.py forums_digest --to_datetime=2017-10-24 --users=8
# verify no errors in log
tail -n 100 /edx/var/log/supervisor/notifier-celery-workers-stderr.log