diff --git a/app/Jobs/SendPolicyAnnouncementJob.php b/app/Jobs/SendPolicyAnnouncementJob.php index b4b48b98..75a835ab 100644 --- a/app/Jobs/SendPolicyAnnouncementJob.php +++ b/app/Jobs/SendPolicyAnnouncementJob.php @@ -6,6 +6,16 @@ use App\User; use Illuminate\Support\Facades\Notification; +/** + * WARNING: This job is NOT idempotent. DO NOT RUN IT MULTIPLE TIMES. + * There is also no error handling or mechanism for recording which users have been sent an email. + * + * This has created an issue on production where a user with an empty string as an email address + * (due to a request to remove PII) caused Notification::send() to throw an error and the remaining + * emails to not be sent. + * + * DO NOT REPEAT THIS PATTERN FOR OTHER JOBS + */ class SendPolicyAnnouncementJob extends Job { public function handle() { $users = User::query()->whereNotNull('email')->get();