Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions app/Http/Controllers/Backend/WikiReadOnlyController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers\Backend;

use App\Http\Controllers\Controller;
use App\Wiki;
use Illuminate\Http\Request;

class WikiReadOnlyController extends Controller {

public function getWikiVersionForDomain(Request $request) {

$domain = $request->query('domain');
$wiki = Wiki::where('domain', $domain)->first();

if (!$wiki) {
return response()->json([
'error' => 'Wiki not found for domain: ' . $domain
], 404);
}

$wiki->setSetting('wgReadOnly', 'This wiki is currently read-only.');
return response()->json([
'success' => true,
'domain' => $domain,
'message' => 'Wiki set to read-only successfully.',
]);
}

}
7 changes: 7 additions & 0 deletions app/Wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,11 @@ public function getDomainDecodedAttribute(): string {
public function wikiLatestProfile() {
return $this->hasOne(WikiProfile::class)->latestOfMany();
}

public function setSetting(string $name, string $value): void {
$this->settings()->updateOrCreate(
['name' => $name],
['value' => $value]
);
}
}
1 change: 1 addition & 0 deletions routes/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// GET
$router->get('healthz', fn () => "It's Alive");
$router->get('getWikiHostsForDomain', ['uses' => 'MediaWikiHostsController@getWikiHostsForDomain']);
$router->post('setWikiReadonly', ['uses' => 'WikiReadOnlyController@setWikiReadonly']);

$router->group(['prefix' => 'ingress'], function () use ($router) {
// GET
Expand Down
Loading