+ users = User.objects.filter(subscription_settings__enable_notifications=True,
+ subscription_settings__send_digest=True)
+
+ # Send digest only to active users
+ if settings.SEND_DIGEST_ONLY_TO_ACTIVE_USERS:
+ users = users.filter(is_active=True)
+
+ # Send digest only to users with validated emails
+ if settings.SEND_DIGEST_ONLY_TO_VALIDATED_USERS:
+ users = users.filter(email_isvalid=True)
+