-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Custom SMTP Settings * Fix lint * Custom SMTP add in Pricing plan * Allow reset email settings * improve custom SMTP using seprate abstract class * test case for custom SMTP * fix test case * UI improvement * add CASHIER_KEY in phpunit for testcase * Attempt to fix tests * Run pint and attempt to fix cache tests * Fix user management tests * Fix code linters * Merged main & fix linting --------- Co-authored-by: Julien Nahum <[email protected]>
- Loading branch information
1 parent
5dcd4ff
commit 504c7a0
Showing
31 changed files
with
876 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Workspace; | ||
|
||
use App\Models\Workspace; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Http\Request; | ||
|
||
class EmailSettingsRequest extends FormRequest | ||
{ | ||
public Workspace $workspace; | ||
|
||
public function __construct(Request $request, Workspace $workspace) | ||
{ | ||
$this->workspace = Workspace::findOrFail($request->workspaceId); | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function rules() | ||
{ | ||
$allFieldsPresent = $this->filled(['host', 'port', 'username', 'password']); | ||
|
||
return [ | ||
'host' => [ | ||
$allFieldsPresent ? 'required' : 'nullable', | ||
'required_with:port,username,password', | ||
'string', | ||
], | ||
'port' => [ | ||
$allFieldsPresent ? 'required' : 'nullable', | ||
'required_with:host,username,password', | ||
'integer', | ||
], | ||
'username' => [ | ||
$allFieldsPresent ? 'required' : 'nullable', | ||
'required_with:host,port,password', | ||
'string', | ||
], | ||
'password' => [ | ||
$allFieldsPresent ? 'required' : 'nullable', | ||
'required_with:host,port,username', | ||
'string', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Get the validation messages that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function messages() | ||
{ | ||
return [ | ||
'host.required_with' => 'The host field is required.', | ||
'port.required_with' => 'The port field is required.', | ||
'username.required_with' => 'The username field is required.', | ||
'password.required_with' => 'The password field is required.', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
api/app/Integrations/Handlers/AbstractEmailIntegrationHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Integrations\Handlers; | ||
|
||
use App\Events\Forms\FormSubmitted; | ||
use App\Models\Integration\FormIntegration; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
abstract class AbstractEmailIntegrationHandler extends AbstractIntegrationHandler | ||
{ | ||
protected $mailer; | ||
|
||
public function __construct(FormSubmitted $event, FormIntegration $formIntegration, array $integration) | ||
{ | ||
parent::__construct($event, $formIntegration, $integration); | ||
$this->initializeMailer(); | ||
} | ||
|
||
protected function initializeMailer() | ||
{ | ||
$this->mailer = config('mail.default'); | ||
$this->setWorkspaceSMTPSettings(); | ||
|
||
if (!$this->mailer) { | ||
Log::error('Mailer not specified', [ | ||
'form_id' => $this->form->id | ||
]); | ||
} | ||
} | ||
|
||
protected function setWorkspaceSMTPSettings() | ||
{ | ||
$workspace = $this->form->workspace; | ||
$emailSettings = $workspace->settings['email_settings'] ?? []; | ||
if (!$workspace->is_pro || !$emailSettings || empty($emailSettings['host']) || empty($emailSettings['port']) || empty($emailSettings['username']) || empty($emailSettings['password'])) { | ||
return; | ||
} | ||
|
||
config([ | ||
'mail.mailers.custom_smtp.host' => $emailSettings['host'], | ||
'mail.mailers.custom_smtp.port' => $emailSettings['port'], | ||
'mail.mailers.custom_smtp.username' => $emailSettings['username'], | ||
'mail.mailers.custom_smtp.password' => $emailSettings['password'] | ||
]); | ||
$this->mailer = 'custom_smtp'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.