Changes to documents able to edit them now, also support for auto mail attechemnts
This commit is contained in:
@@ -22,7 +22,7 @@ public function __construct(public EmailTemplateRenderer $renderer) {}
|
||||
* Attempt to queue an auto mail for the given activity based on its decision/template.
|
||||
* Returns array with either ['queued' => true, 'log_id' => int] or ['skipped' => 'reason'].
|
||||
*/
|
||||
public function maybeQueue(Activity $activity, bool $sendFlag = true): array
|
||||
public function maybeQueue(Activity $activity, bool $sendFlag = true, array $options = []): array
|
||||
{
|
||||
$decision = $activity->decision;
|
||||
if (! $sendFlag || ! $decision || ! $decision->auto_mail || ! $decision->email_template_id) {
|
||||
@@ -114,6 +114,24 @@ public function maybeQueue(Activity $activity, bool $sendFlag = true): array
|
||||
if (count($recipients) > 1) {
|
||||
$log->to_email = null;
|
||||
}
|
||||
// Resolve and attach selected documents as attachments metadata (id, name, path, mime, size)
|
||||
$attachmentIds = collect($options['attachment_ids'] ?? [])->filter()->map(fn ($v) => (int) $v)->values();
|
||||
if ($attachmentIds->isNotEmpty()) {
|
||||
$docs = \App\Models\Document::query()
|
||||
->whereIn('id', $attachmentIds)
|
||||
->get(['id', 'disk', 'path', 'original_name', 'name', 'mime_type', 'size']);
|
||||
$log->attachments = $docs->map(function ($d) {
|
||||
return [
|
||||
'id' => $d->id,
|
||||
'disk' => $d->disk ?: 'public',
|
||||
'path' => $d->path,
|
||||
'name' => $d->original_name ?: ($d->name ?: basename($d->path)),
|
||||
'mime' => $d->mime_type ?: 'application/octet-stream',
|
||||
'size' => $d->size,
|
||||
];
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
$log->save();
|
||||
|
||||
$log->body()->create([
|
||||
|
||||
Reference in New Issue
Block a user