1
0
Fork 0

Merge pull request #4360 from pixelfed/staging

Staging
This commit is contained in:
daniel 2023-05-07 05:26:41 -06:00 committed by GitHub
commit c996f37366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 69 additions and 30 deletions

View File

@ -41,10 +41,10 @@ jobs:
- vendor
- run: cp .env.testing .env
- run: php artisan config:cache
- run: php artisan route:clear
- run: php artisan storage:link
- run: php artisan key:generate
- run: php artisan config:clear
# run tests with phpunit or codecept
- run: ./vendor/bin/phpunit

View File

@ -65,3 +65,5 @@ CS_UNLISTED_DOMAINS='example.org,example.net,example.com'
## Optional
#HORIZON_DARKMODE=false # Horizon theme darkmode
#HORIZON_EMBED=false # Single Docker Container mode
ENABLE_CONFIG_CACHE=false

View File

@ -2,11 +2,18 @@
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.6...dev)
### Added
- Added store remote media on S3 config setting, disabled by default ([51768083](https://github.com/pixelfed/pixelfed/commit/51768083))
### Updates
- Update admin dashboard, fix search and dropdown menu ([dac0d083](https://github.com/pixelfed/pixelfed/commit/dac0d083))
- Update sudo mode view, fix trusted device checkbox ([8ef900bf](https://github.com/pixelfed/pixelfed/commit/8ef900bf))
- Update SearchApiV2Service, improve postgres support ([666e5732](https://github.com/pixelfed/pixelfed/commit/666e5732))
- Update StoryController, show active self stories on home timeline ([633351f6](https://github.com/pixelfed/pixelfed/commit/633351f6))
- Update ApiV1Controller, fix trending accounts format. Closes #4356 ([37bd2ee5](https://github.com/pixelfed/pixelfed/commit/37bd2ee5))
- Update instance config, enable config cache by default ([970f77b0](https://github.com/pixelfed/pixelfed/commit/970f77b0))
- Update Admin Dashboard, allow admins to designate an admin account for the landing page and instance api endpoint ([6ea2bdc7](https://github.com/pixelfed/pixelfed/commit/6ea2bdc7))
- Update config, enable oauth by default ([6a2e9e8f](https://github.com/pixelfed/pixelfed/commit/6a2e9e8f))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.6 (2023-05-03)](https://github.com/pixelfed/pixelfed/compare/v0.11.5...v0.11.6)

View File

@ -10,8 +10,10 @@ use App\Models\InstanceActor;
use App\Http\Controllers\Controller;
use App\Util\Lexer\PrettyNumber;
use App\Models\ConfigCache;
use App\Services\AccountService;
use App\Services\ConfigCacheService;
use App\Util\Site\Config;
use Illuminate\Support\Str;
trait AdminSettingsController
{
@ -28,6 +30,9 @@ trait AdminSettingsController
$mp4 = in_array('video/mp4', $types);
$webp = in_array('image/webp', $types);
$availableAdmins = User::whereIsAdmin(true)->get();
$currentAdmin = config_cache('instance.admin.pid') ? AccountService::get(config_cache('instance.admin.pid'), true) : null;
// $system = [
// 'permissions' => is_writable(base_path('storage')) && is_writable(base_path('bootstrap')),
// 'max_upload_size' => ini_get('post_max_size'),
@ -45,6 +50,8 @@ trait AdminSettingsController
'cloud_storage',
'cloud_disk',
'cloud_ready',
'availableAdmins',
'currentAdmin'
// 'system'
));
}
@ -63,8 +70,14 @@ trait AdminSettingsController
'type_gif' => 'nullable',
'type_mp4' => 'nullable',
'type_webp' => 'nullable',
'admin_account_id' => 'nullable',
]);
if($request->filled('admin_account_id')) {
ConfigCacheService::put('instance.admin.pid', $request->admin_account_id);
Cache::forget('api:v1:instance-data:contact');
Cache::forget('api:v1:instance-data-response-v1');
}
if($request->filled('rule_delete')) {
$index = (int) $request->input('rule_delete');
$rules = ConfigCacheService::get('app.rules');
@ -75,8 +88,8 @@ trait AdminSettingsController
unset($json[$index]);
$json = json_encode(array_values($json));
ConfigCacheService::put('app.rules', $json);
Cache::forget('api:v1:instance-data:rules');
Cache::forget('api:v1:instance-data-response-v1');
Cache::forget('api:v1:instance-data:rules');
Cache::forget('api:v1:instance-data-response-v1');
return 200;
}
@ -124,8 +137,8 @@ trait AdminSettingsController
if($cc && $cc->v != $val) {
ConfigCacheService::put($value, $val);
} else if(!empty($val)) {
ConfigCacheService::put($value, $val);
}
ConfigCacheService::put($value, $val);
}
}
$bools = [
@ -141,8 +154,8 @@ trait AdminSettingsController
'show_custom_js' => 'uikit.show_custom.js',
'cloud_storage' => 'pixelfed.cloud_storage',
'account_autofollow' => 'account.autofollow',
'show_directory' => 'landing.show_directory',
'show_explore_feed' => 'landing.show_explore_feed',
'show_directory' => 'instance.landing.show_directory',
'show_explore_feed' => 'instance.landing.show_explore',
];
foreach ($bools as $key => $value) {

View File

@ -1554,6 +1554,9 @@ class ApiV1Controller extends Controller
{
$res = Cache::remember('api:v1:instance-data-response-v1', 1800, function () {
$contact = Cache::remember('api:v1:instance-data:contact', 604800, function () {
if(config_cache('instance.admin.pid')) {
return AccountService::getMastodon(config_cache('instance.admin.pid'), true);
}
$admin = User::whereIsAdmin(true)->first();
return $admin && isset($admin->profile_id) ?
AccountService::getMastodon($admin->profile_id, true) :

View File

@ -15,7 +15,7 @@ class LandingController extends Controller
return redirect('/');
}
abort_if(config('instance.landing.show_directory') == false, 404);
abort_if(config_cache('instance.landing.show_directory') == false, 404);
return view('site.index');
}
@ -26,14 +26,14 @@ class LandingController extends Controller
return redirect('/');
}
abort_if(config('instance.landing.show_explore') == false, 404);
abort_if(config_cache('instance.landing.show_explore') == false, 404);
return view('site.index');
}
public function getDirectoryApi(Request $request)
{
abort_if(config('instance.landing.show_directory') == false, 404);
abort_if(config_cache('instance.landing.show_directory') == false, 404);
return DirectoryProfile::collection(
Profile::whereNull('domain')

View File

@ -24,7 +24,7 @@ class AuthServiceProvider extends ServiceProvider
*/
public function boot()
{
if(config_cache('pixelfed.oauth_enabled') == true) {
if(config('app.env') === 'production' && config('pixelfed.oauth_enabled') == true) {
Passport::tokensExpireIn(now()->addDays(config('instance.oauth.token_expiration', 356)));
Passport::refreshTokensExpireIn(now()->addDays(config('instance.oauth.refresh_expiration', 400)));
Passport::enableImplicitGrant();

View File

@ -65,6 +65,10 @@ class ConfigCacheService
'pixelfed.directory.latest_response',
'pixelfed.directory.is_synced',
'pixelfed.directory.testimonials',
'instance.landing.show_directory',
'instance.landing.show_explore',
'instance.admin.pid',
// 'system.user_mode'
];

View File

@ -30,6 +30,9 @@ class LandingService
});
$contactAccount = Cache::remember('api:v1:instance-data:contact', 604800, function () {
if(config_cache('instance.admin.pid')) {
return AccountService::getMastodon(config_cache('instance.admin.pid'), true);
}
$admin = User::whereIsAdmin(true)->first();
return $admin && isset($admin->profile_id) ?
AccountService::getMastodon($admin->profile_id, true) :
@ -53,8 +56,8 @@ class LandingService
'name' => config_cache('app.name'),
'url' => config_cache('app.url'),
'domain' => config('pixelfed.domain.app'),
'show_directory' => config('instance.landing.show_directory'),
'show_explore_feed' => config('instance.landing.show_explore'),
'show_directory' => config_cache('instance.landing.show_directory'),
'show_explore_feed' => config_cache('instance.landing.show_explore'),
'open_registration' => config_cache('pixelfed.open_registration') == 1,
'version' => config('pixelfed.version'),
'about' => [

View File

@ -89,7 +89,7 @@ return [
]
],
'enable_cc' => env('ENABLE_CONFIG_CACHE', false),
'enable_cc' => env('ENABLE_CONFIG_CACHE', true),
'has_legal_notice' => env('INSTANCE_LEGAL_NOTICE', false),

View File

@ -255,7 +255,7 @@ return [
]
],
'oauth_enabled' => env('OAUTH_ENABLED', false),
'oauth_enabled' => env('OAUTH_ENABLED', true),
'bouncer' => [
'enabled' => env('PF_BOUNCER_ENABLED', false),

View File

@ -148,36 +148,43 @@
<div class="tab-pane" id="landing" role="tabpanel" aria-labelledby="landing-tab">
<div class="form-group mb-0">
<div class="ml-n4 mr-n2 p-3 border-top border-bottom">
<label class="font-weight-bold text-muted">Name</label>
<input class="form-control col-8" name="name" placeholder="Pixelfed" value="{{config_cache('app.name')}}" disabled>
<p class="help-text small text-muted mt-3 mb-0">The instance name. Change in Brand section.</p>
<p class="mb-0 small">Configure your landing page</p>
</div>
</div>
<div class="form-group mb-0">
<div class="ml-n4 mr-n2 p-3 border-bottom">
<label class="font-weight-bold text-muted">About</label>
<textarea class="form-control" rows="3" name="long_description" disabled>{{config_cache('app.description')}}</textarea>
<p class="help-text small text-muted mt-3 mb-0">Description of instance used on about section. Change in Brand section.</p>
</div>
</div>
<div class="form-group mb-0">
<div class="ml-n4 mr-n2 p-3 border-bottom">
<label class="font-weight-bold text-muted">Other Settings</label>
<p class="font-weight-bold text-muted">Discovery</p>
<div class="my-3">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="show_directory" name="show_directory" {{ config('instance.landing.show_directory') ? 'checked' : ''}} disabled>
<input type="checkbox" class="custom-control-input" id="show_directory" name="show_directory" {{ config_cache('instance.landing.show_directory') ? 'checked' : ''}}>
<label class="custom-control-label font-weight-bold" for="show_directory">Show Directory</label>
</div>
<p class="help-text small text-muted mt-3 mb-0">To disable the Directory, set <code>INSTANCE_LANDING_SHOW_DIRECTORY=false</code> in .env</p>
</div>
<div class="my-3">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="show_explore_feed" name="show_explore_feed" {{ config('instance.landing.show_explore') ? 'checked' : ''}} disabled>
<input type="checkbox" class="custom-control-input" id="show_explore_feed" name="show_explore_feed" {{ config_cache('instance.landing.show_explore') ? 'checked' : ''}}>
<label class="custom-control-label font-weight-bold" for="show_explore_feed">Show Explore Feed</label>
</div>
<p class="help-text small text-muted mt-3 mb-0">To disable the Explore feed, set <code>INSTANCE_LANDING_SHOW_EXPLORE=false</code> in .env</p>
</div>
</div>
</div>
<div class="form-group mb-0">
<div class="ml-n4 mr-n2 p-3 border-bottom">
<p class="font-weight-bold text-muted">Admin Account</p>
<div class="my-3">
<select class="custom-select" name="admin_account_id" style="max-width: 300px;">
<option selected disabled>Select an admin account</option>
@foreach($availableAdmins as $acct)
<option
value="{{ $acct->profile_id }}" {!! $currentAdmin && $currentAdmin['id'] == $acct->profile_id ? 'selected' : null !!}
>
<span class="font-weight-bold">&commat;{{ $acct->username }}</span>
</option>
@endforeach
</select>
</div>
</div>
</div>