Skip to content

Commit

Permalink
fix(SFT-1690): export notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavs-gutmanis committed Jan 6, 2025
1 parent 52c4084 commit b448377
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Solspace\Freeform\Library\Bundles\FeatureBundle;
use Solspace\Freeform\Library\DataObjects\NotificationTemplate;
use Solspace\Freeform\Library\Exceptions\FreeformException;
use Solspace\Freeform\Library\Helpers\EncryptionHelper;
use Solspace\Freeform\Notifications\Components\Recipients\RecipientCollection;
use Solspace\Freeform\Records\NotificationLogRecord;
use Solspace\Freeform\Records\NotificationTemplateRecord;
Expand Down Expand Up @@ -91,20 +90,23 @@ public function handleNotifications(): void
$message = $mailer->compileMessage($template, $variables);
$message->setTo($mailer->processRecipients($recipients));

$data = $profile->getQuery();

$key = EncryptionHelper::getKey($form->getUid());
$data = EncryptionHelper::decryptExportData($key, $data);

$exporter = $exportService->createExporter($notification->fileType, $form, $data);
$exporter = $exportService->createExporter(
$notification->fileType,
$form,
$profile->getQuery(),
$profile->getFieldDescriptors()
);

$fileName = $mailer->renderString(
$notification->fileName ?? '',
$variables
);

$exportFile = tmpfile();
$exporter->export($exportFile);

$message->attachContent(
$exporter->export(),
$exportFile,
[
'fileName' => $fileName.'.'.$exporter->getFileExtension(),
'contentType' => $exporter->getMimeType(),
Expand Down

0 comments on commit b448377

Please sign in to comment.