diff --git a/app/Http/Controllers/Forms/FormSubmissionController.php b/app/Http/Controllers/Forms/FormSubmissionController.php
index dca04b1..2eec417 100644
--- a/app/Http/Controllers/Forms/FormSubmissionController.php
+++ b/app/Http/Controllers/Forms/FormSubmissionController.php
@@ -37,7 +37,8 @@ class FormSubmissionController extends Controller
$formatter = (new FormSubmissionFormatter($form, $row['data']))
->outputStringsOnly()
->setEmptyForNoValue()
- ->showRemovedFields();
+ ->showRemovedFields()
+ ->useSignedUrlForFiles();
$tmp = $formatter->getCleanKeyValue();
$tmp['Create Date'] = date("Y-m-d H:i", strtotime($row['created_at']));
$allRows[] = $tmp;
diff --git a/app/Mail/Forms/SubmissionConfirmationMail.php b/app/Mail/Forms/SubmissionConfirmationMail.php
index 6532e94..4e8da4b 100644
--- a/app/Mail/Forms/SubmissionConfirmationMail.php
+++ b/app/Mail/Forms/SubmissionConfirmationMail.php
@@ -35,7 +35,8 @@ class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
$formatter = (new FormSubmissionFormatter($form, $this->event->data))
->createLinks()
- ->outputStringsOnly();
+ ->outputStringsOnly()
+ ->useSignedUrlForFiles();
return $this
->replyTo($this->getReplyToEmail($form->creator->email))
diff --git a/app/Notifications/Forms/FormSubmissionNotification.php b/app/Notifications/Forms/FormSubmissionNotification.php
index 94196e3..889f11c 100644
--- a/app/Notifications/Forms/FormSubmissionNotification.php
+++ b/app/Notifications/Forms/FormSubmissionNotification.php
@@ -49,7 +49,8 @@ class FormSubmissionNotification extends Notification implements ShouldQueue
$formatter = (new FormSubmissionFormatter($this->event->form, $this->event->data))
->showHiddenFields()
->createLinks()
- ->outputStringsOnly();
+ ->outputStringsOnly()
+ ->useSignedUrlForFiles();
return (new MailMessage)
->replyTo($this->getReplyToEmail($notifiable->routes['mail']))
diff --git a/app/Service/Forms/FormSubmissionFormatter.php b/app/Service/Forms/FormSubmissionFormatter.php
index 44534e2..d46fe50 100644
--- a/app/Service/Forms/FormSubmissionFormatter.php
+++ b/app/Service/Forms/FormSubmissionFormatter.php
@@ -29,6 +29,8 @@ class FormSubmissionFormatter
private $showRemovedFields = false;
+ private $useSignedUrlForFiles = false;
+
/**
* Logic resolver needs an array id => value, so we create it here
*/
@@ -69,6 +71,12 @@ class FormSubmissionFormatter
return $this;
}
+ public function useSignedUrlForFiles()
+ {
+ $this->useSignedUrlForFiles = true;
+ return $this;
+ }
+
/**
* Return a nice "FieldName": "Field Response" array
* - If createLink enabled, returns html link for emails and links
@@ -117,14 +125,14 @@ class FormSubmissionFormatter
$formId = $this->form->id;
$returnArray[$field['name']] = implode(', ',
collect($data[$field['id']])->map(function ($file) use ($formId) {
- return route('open.forms.submissions.file', [$formId, $file]);
+ return $this->getFileUrl($formId, $file);
})->toArray()
);
} else {
$formId = $this->form->id;
$returnArray[$field['name']] = collect($data[$field['id']])->map(function ($file) use ($formId) {
return [
- 'file_url' => route('open.forms.submissions.file', [$formId, $file]),
+ 'file_url' => $this->getFileUrl($formId, $file),
'file_name' => $file,
];
});
@@ -185,14 +193,22 @@ class FormSubmissionFormatter
$formId = $this->form->id;
$field['value'] = implode(', ',
collect($data[$field['id']])->map(function ($file) use ($formId) {
- return route('open.forms.submissions.file', [$formId, $file]);
+ return $this->getFileUrl($formId, $file);
})->toArray()
);
+ $field['email_data'] = collect($data[$field['id']])->map(function ($file) use ($formId) {
+ $splitText = explode('.', $file);
+ return [
+ "unsigned_url" => route('open.forms.submissions.file', [$formId, $file]),
+ "signed_url" => $this->getFileUrl($formId, $file),
+ "label" => \Str::limit($file, 20, '[...].'.end($splitText))
+ ];
+ })->toArray();
} else {
$formId = $this->form->id;
$field['value'] = collect($data[$field['id']])->map(function ($file) use ($formId) {
return [
- 'file_url' => route('open.forms.submissions.file', [$formId, $file]),
+ 'file_url' => $this->getFileUrl($formId, $file),
'file_name' => $file,
];
});
@@ -222,4 +238,11 @@ class FormSubmissionFormatter
}
}
+ private function getFileUrl($formId, $file)
+ {
+ return $this->useSignedUrlForFiles ? \URL::signedRoute(
+ 'open.forms.submissions.file',
+ [$formId, $file]) : route('open.forms.submissions.file', [$formId, $file]);
+ }
+
}
diff --git a/resources/views/mail/form/confirmation-submission-notification.blade.php b/resources/views/mail/form/confirmation-submission-notification.blade.php
index 86c3ebe..c85059c 100644
--- a/resources/views/mail/form/confirmation-submission-notification.blade.php
+++ b/resources/views/mail/form/confirmation-submission-notification.blade.php
@@ -17,9 +17,14 @@ As a reminder, here are your answers:
--------------------------------------------------------------------------------
**{{$field['name']}}**
-
+@if($field['type'] == 'files')
+
+@foreach($field['email_data'] as $link)
+{{$link['label']}}
+@endforeach
+@else
{!! is_array($field['value'])?implode(',',$field['value']):$field['value']!!}
-
+@endif
@endif
@endforeach
@endif
diff --git a/resources/views/mail/form/submission-notification.blade.php b/resources/views/mail/form/submission-notification.blade.php
index b877a4c..f421359 100644
--- a/resources/views/mail/form/submission-notification.blade.php
+++ b/resources/views/mail/form/submission-notification.blade.php
@@ -10,9 +10,14 @@ Your form "{{$form->title}}" has a new submission.
--------------------------------------------------------------------------------
**{{$field['name']}}**
-
+@if($field['type'] == 'files')
+
+@foreach($field['email_data'] as $link)
+{{$link['label']}}
+@endforeach
+@else
{!! is_array($field['value'])?implode(',',$field['value']):$field['value']!!}
-
+@endif
@endif
@endforeach