Factor out notification logic.