wip(Resiliation script)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
namespace App\Services\Dolibarr;
|
||||
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
@@ -58,4 +58,15 @@ class DolibarrService
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
public function setMemberStatus(int|string $id, string $status): bool
|
||||
{
|
||||
$response = $this->client()->put(
|
||||
$this->baseUrl . '/members/' . $id,
|
||||
['status' => $status]
|
||||
);
|
||||
|
||||
return $response->successful();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,4 +87,20 @@ class ISPConfigMailService extends ISPConfigService
|
||||
'spam_filter' => $user['move_junk'] === 'y',
|
||||
];
|
||||
}
|
||||
|
||||
public function updateMailUser(string $email, array $changes): bool
|
||||
{
|
||||
$allUsers = $this->getAllMailUsers();
|
||||
$user = collect($allUsers)->firstWhere('email', $email);
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->call('mail_user_update', [
|
||||
'primary_id' => $user['mailuser_id'],
|
||||
'params' => $changes,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
26
app/Services/Nextcloud/NextcloudService.php
Normal file
26
app/Services/Nextcloud/NextcloudService.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Nextcloud;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class NextcloudService
|
||||
{
|
||||
public function disableUserByEmail(string $email): bool
|
||||
{
|
||||
$username = $this->getUsernameFromEmail($email);
|
||||
|
||||
return Http::withBasicAuth(
|
||||
config('services.nextcloud.username'),
|
||||
config('services.nextcloud.password')
|
||||
)->put(
|
||||
config('services.nextcloud.base_url') . "/ocs/v1.php/cloud/users/{$username}/disable",
|
||||
[]
|
||||
)->successful();
|
||||
}
|
||||
|
||||
protected function getUsernameFromEmail(string $email): string
|
||||
{
|
||||
return strstr($email, '@', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user