novas funcionalidades dos formulario
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-02 11:13:37 +02:00
parent a6afb4e97a
commit 4f35313d06
104 changed files with 7653 additions and 178 deletions
+27 -2
View File
@@ -16,7 +16,8 @@ final class InterestSubmission
*/
public function receive(#[SensitiveParameter] array $payload, #[SensitiveParameter] ?string $key, Closure $create): InterestRequest
{
$canonical = array_replace(['phone' => null, 'opportunityReference' => null, 'investmentRange' => null], $payload);
$canonical = array_replace(['phone' => null, 'opportunityReference' => null, 'existingBusinessId' => null,
'modality' => null, 'investmentRange' => null, 'shareWithProponent' => false], $payload);
$canonical['email'] = strtolower(trim($canonical['email']));
$canonical['fullName'] = trim($canonical['fullName']);
$canonical['message'] = trim($canonical['message']);
@@ -25,7 +26,7 @@ final class InterestSubmission
$payloadHash = hash_hmac('sha256', json_encode($canonical, JSON_THROW_ON_ERROR), config()->string('app.key'));
$keyHash = $key === null ? null : hash('sha256', strtolower($key));
return DB::transaction(function () use ($keyHash, $payloadHash, $create): InterestRequest {
return DB::transaction(function () use ($keyHash, $payloadHash, $create, $canonical): InterestRequest {
if ($keyHash !== null) {
// Serialise concurrent submissions of this key across all web workers.
DB::select('select pg_advisory_xact_lock(250925, hashtext(?))', [$keyHash]);
@@ -41,6 +42,10 @@ final class InterestSubmission
$interest = $create();
$integrationId = (string) Str::uuid();
$interest->forceFill(['integration_id' => $integrationId])->save();
$this->recordConsent($interest, $integrationId, 'respond_to_interest', config('existing-business.consent_policy_version'));
if ($canonical['shareWithProponent'] === true || $canonical['shareWithProponent'] === 1 || $canonical['shareWithProponent'] === '1') {
$this->recordConsent($interest, $integrationId, 'share_contact_with_proponent', config('existing-business.sharing_policy_version'));
}
DB::table('outbox_events')->insert([
'source_system' => 'portal-intake',
'external_id' => 'ExpressionOfInterestSubmitted:'.$integrationId,
@@ -59,4 +64,24 @@ final class InterestSubmission
return $interest;
});
}
private function recordConsent(InterestRequest $interest, string $correlationId, string $purpose, string $policyVersion): void
{
DB::table('consents')->insert([
'id' => (string) Str::uuid(),
'source_system' => 'portal-intake',
'external_id' => 'InterestConsent:'.$interest->integration_id.':'.$purpose,
'version_no' => 1,
'data_classification' => 'confidential',
'correlation_id' => $correlationId,
'subject_ref' => $interest->reference,
'purpose' => $purpose,
'status' => 'granted',
'granted_at' => now(),
'interest_request_id' => $interest->id,
'policy_version' => $policyVersion,
'created_at' => now(),
'updated_at' => now(),
]);
}
}