ro
8c375e6ba1
setting sync is working but member data was not being updated in the folks file or in the current active session, so that's been addressed still need to turn on avatar updating as well, but that is tied to updating the settings page, so that will be handled when image uploads for that area are reactivated
80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Services\Data\SettingsService;
|
|
use App\Services\Assets\RenderService;
|
|
use App\Services\Upkeep\MaintenanceService;
|
|
use App\Interfaces\MemberRepositoryInterface;
|
|
use App\Services\Assets\AssetService;
|
|
|
|
class SettingsAPIController extends Controller
|
|
{
|
|
protected $settings;
|
|
protected $render;
|
|
protected $mainteance;
|
|
protected $member;
|
|
protected $assets;
|
|
|
|
public function __construct(
|
|
SettingsService $settingsService,
|
|
RenderService $renderService,
|
|
MaintenanceService $maintenanceService,
|
|
MemberRepositoryInterface $memberRepo,
|
|
AssetService $assetService
|
|
) {
|
|
$this->settings = $settingsService;
|
|
$this->render = $renderService;
|
|
$this->maintenance = $maintenanceService;
|
|
$this->member = $memberRepo;
|
|
$this->assets = $assetService;
|
|
}
|
|
|
|
public function publish(Request $request)
|
|
{
|
|
$this->assets->moveToTheme(true);
|
|
$result = $this->render->publishAll();
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function sync(Request $request)
|
|
{
|
|
$body = json_decode($request->getContent());
|
|
//update member if needed
|
|
$this->member->update($body->member);
|
|
//sync settings
|
|
$result = $this->settings->sync($body);
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function navSync(Request $request)
|
|
{
|
|
$body = json_decode($request->getContent());
|
|
$result = $this->settings->navSync($body);
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function createBackup(Request $request)
|
|
{
|
|
return response()->json($this->maintenance->createBackup())->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function downloadBackup(Request $request)
|
|
{
|
|
if ($this->member::status()) {
|
|
$latest = $this->settings->getGlobal()['last_backup'];
|
|
$file = 'backup-' . $latest . '.zip';
|
|
return response()->download('../content/backups/' . $file, $file, ['Content-Type: application/zip']);
|
|
}
|
|
}
|
|
|
|
//init stuff
|
|
public function setupFresh(Request $request)
|
|
{
|
|
$body = json_decode($request->getContent());
|
|
dd($body);
|
|
}
|
|
}
|