Linter fix

This commit is contained in:
Matej Bačo
2026-04-20 11:29:13 +02:00
parent c4d9c3dc4f
commit 06a2d48deb
2 changed files with 15 additions and 15 deletions
@@ -94,7 +94,7 @@ class Update extends Action
): void {
// Fetch current configuration
$smtp = $project->getAttribute('smtp', []);
// Apply changes
$keys = ['host', 'port', 'username', 'password', 'senderEmail', 'senderName', 'replyToEmail', 'replyToName', 'secure', 'enabled'];
foreach ($keys as $key) {
@@ -102,7 +102,7 @@ class Update extends Action
$smtp[$key] = ${$key};
}
}
// Ensure required fields are set
$requiredKeys = ['host', 'port', 'senderEmail'];
foreach ($requiredKeys as $key) {
@@ -110,33 +110,33 @@ class Update extends Action
throw new \Exception('"' . $key . '" is required. Please provide a value.');
}
}
// Validate SMTP credentials
if($smtp['enabled'] === true) {
if ($smtp['enabled'] === true) {
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = $smtp['host'] ?? '';
$mail->Port = $smtp['port'] ?? '';
$mail->SMTPSecure = $smtp['secure'] ?? '';
$mail->setFrom($smtp['senderEmail'], $smtp['senderName'] ?? '');
if(!empty($smtp['username'] ?? '')) {
if (!empty($smtp['username'] ?? '')) {
$mail->SMTPAuth = true;
$mail->Username = $smtp['username'];
$mail->Password = $smtp['password'] ?? '';
}
if(!empty($smtp['replyToEmail'] ?? '')) {
if (!empty($smtp['replyToEmail'] ?? '')) {
$mail->addReplyTo($smtp['replyToEmail'], $smtp['replyToName'] ?? '');
}
$mail->SMTPAutoTLS = false;
$mail->Timeout = 5;
try {
$valid = $mail->SmtpConnect();
if (!$valid) {
throw new \Exception('Connection is not valid.');
}
@@ -149,7 +149,7 @@ class Update extends Action
$updates = new Document([
'smtp' => $smtp,
]);
$project = $authorization->skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), $updates));
$response->dynamic($project, Response::MODEL_PROJECT);
@@ -24,7 +24,7 @@ use Appwrite\Platform\Modules\Project\Http\Project\Platforms\Windows\Update as U
use Appwrite\Platform\Modules\Project\Http\Project\Platforms\XList as ListPlatforms;
use Appwrite\Platform\Modules\Project\Http\Project\Protocols\Status\Update as UpdateProjectProtocolStatus;
use Appwrite\Platform\Modules\Project\Http\Project\Services\Status\Update as UpdateProjectServiceStatus;
use Appwrite\Platform\Modules\Project\Http\Project\SMTP\Credentials\Update as UpdateSMTPCredentials;
use Appwrite\Platform\Modules\Project\Http\Project\SMTP\Update as UpdateSMTP;
use Appwrite\Platform\Modules\Project\Http\Project\SMTP\Tests\Create as CreateSMTPTest;
use Appwrite\Platform\Modules\Project\Http\Project\Variables\Create as CreateVariable;
use Appwrite\Platform\Modules\Project\Http\Project\Variables\Delete as DeleteVariable;
@@ -48,7 +48,7 @@ class Http extends Service
$this->addAction(UpdateProjectServiceStatus::getName(), new UpdateProjectServiceStatus());
// SMTP
$this->addAction(UpdateSMTPCredentials::getName(), new UpdateSMTPCredentials());
$this->addAction(UpdateSMTP::getName(), new UpdateSMTP());
$this->addAction(CreateSMTPTest::getName(), new CreateSMTPTest());
// Variables