-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Ad hoc email command #12325
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good so far. Will verify in dev
return $builder; | ||
} | ||
|
||
private function builderFromNotifictionFamilies(array $notificationFamilies): Builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor typo - builderFromNotificationFamilies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
fix function name typo
($notifyAllUsers ? 1 : 0); | ||
|
||
if ($optionTypesCount != 1) { | ||
throw new \Error('Must filter users using exactly one of the option types'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can simply use InvalidArgumentException .. but your choice :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - that's more descriptive.
switch to InvalidArgumentException
$userCount = $users->count(); | ||
|
||
if ($this->confirm('Do you wish to send notifications to '.$userCount.' users?')) { | ||
$progressBar = $this->output->createProgressBar($userCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oo.. progressbar!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying out some of the new Laravel 11 features. 😉
Sorry for delaying on this what I noticed so far
testing few more things |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned, when the template is mistakenly given it is failing silently
when there is multiple critieras given , I got different exception rather than the invalidargument .. but I'm not too worried about this .. as long as it breaks we know
But if the above one is fixed , would be great.
Also if we can have comma separated emails for bulk email would be great.
Other than that this looks awesome!
Thanks for the review! Some feedback on your requests:
This is because sending emails is an asynchronous process. They aren't sent out when the command is run so we can't immediately display API errors like invalid template ID. That will be logged in log files when the queue worker tries to send it. I don't think we want to make this synchronous either. We need to be able to slow it down to satisfy the API rate limiter and be able to retry later if the service goes offline. This is easy to forget so updated the messages to try to be a bit clearer:
The AC of the issue didn't specify how the options should be sent so I went with the built-in Laravel option: When defining an option that expects multiple input values, each option value passed to the command should be prefixed with the option name. If we want to manually parse a comma separated list we can do that but let's decide on a method and add it to the AC. @tristan-orourke , preferences?
In your screenshot it looks like your log file is not writable which is an unrelated error. I think we will get the right exception for multiple criteria. |
Ah, I didn't realize Laravel had a built-in option like that for list inputs. Hmmm. When we need to use this command, we're likely to be starting from a comma-separated list of emails... However, it would only take a bit of find/replace in a text editor to modify that. Let's stick to the Laravel spec, and keep it as is. |
This error was on dev. I can try again. Could be related to the issue you solved yesterday |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
🤖 Resolves #11542
👋 Introduction
Adds an Artisan command and Laravel notification for sending ad hoc emails with just the first name and last name.
🕵️ Details
The command will select users to notify by one of three criteria:
🧪 Testing
./artisan send-notifications:ad-hoc-email cdaa82f1-7f76-4d9e-a82e-328c41a6ab62 0831e036-8dfb-4f5e-8b31-867b2c526d77 [email protected] [email protected]
./artisan send-notifications:ad-hoc-email cdaa82f1-7f76-4d9e-a82e-328c41a6ab62 0831e036-8dfb-4f5e-8b31-867b2c526d77 --notificationFamily=JOB_ALERT --notificationFamily=APPLICATION_UPDATE
./artisan send-notifications:ad-hoc-email cdaa82f1-7f76-4d9e-a82e-328c41a6ab62 0831e036-8dfb-4f5e-8b31-867b2c526d77 --notifyAllUsers
📸 Screenshot