mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #16361 from Godmartinz/acceptancer_reminder_unlisted_email_info
Fixed acceptance reminder command lag on users with no associated email
This commit is contained in:
commit
2ff47edb94
|
@ -64,6 +64,7 @@ class SendAcceptanceReminder extends Command
|
|||
->groupBy(function($item) {
|
||||
return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : '';
|
||||
});
|
||||
$no_email_list= [];
|
||||
|
||||
foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {
|
||||
// The [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user.
|
||||
|
@ -72,7 +73,10 @@ class SendAcceptanceReminder extends Command
|
|||
$locale = $acceptance->assignedTo?->locale;
|
||||
$email = $acceptance->assignedTo?->email;
|
||||
if(!$email){
|
||||
$this->info($acceptance->assignedTo?->present()->fullName().' has no email address.');
|
||||
$no_email_list[] = [
|
||||
'id' => $acceptance->assignedTo->id,
|
||||
'name' => $acceptance->assignedTo->present()->fullName(),
|
||||
];
|
||||
}
|
||||
$item_count = $unacceptedAssetGroup->count();
|
||||
|
||||
|
@ -86,6 +90,14 @@ class SendAcceptanceReminder extends Command
|
|||
}
|
||||
|
||||
$this->info($count.' users notified.');
|
||||
$headers = ['ID', 'Name'];
|
||||
$rows = [];
|
||||
|
||||
foreach ($no_email_list as $user) {
|
||||
$rows[] = [$user['id'], $user['name']];
|
||||
}
|
||||
$this->info("The following users do not have an email address:");
|
||||
$this->table($headers, $rows);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,9 +43,13 @@ class SendAcceptanceReminderTest extends TestCase
|
|||
CheckoutAcceptance::factory()->pending()->create([
|
||||
'assigned_to_id' => $userA->id,
|
||||
]);
|
||||
|
||||
$headers = ['ID', 'Name'];
|
||||
$rows = [
|
||||
[$userA->id, $userA->present()->fullName()],
|
||||
];
|
||||
$this->artisan('snipeit:acceptance-reminder')
|
||||
->expectsOutput($userA->present()->fullName().' has no email address.')
|
||||
->expectsOutput("The following users do not have an email address:")
|
||||
->expectsTable($headers, $rows)
|
||||
->assertExitCode(0);
|
||||
|
||||
Mail::assertNotSent(UnacceptedAssetReminderMail::class);
|
||||
|
|
Loading…
Reference in a new issue