mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add account migration configurable, but enabled by default
This commit is contained in:
parent
45bdfe1efd
commit
4a6be62128
10 changed files with 202 additions and 147 deletions
|
@ -2,18 +2,18 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use Artisan, Cache, DB;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use App\{Comment, Like, Media, Page, Profile, Report, Status, User};
|
|
||||||
use App\Models\InstanceActor;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Util\Lexer\PrettyNumber;
|
|
||||||
use App\Models\ConfigCache;
|
use App\Models\ConfigCache;
|
||||||
|
use App\Models\InstanceActor;
|
||||||
|
use App\Page;
|
||||||
|
use App\Profile;
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
use App\Services\ConfigCacheService;
|
use App\Services\ConfigCacheService;
|
||||||
|
use App\User;
|
||||||
use App\Util\Site\Config;
|
use App\Util\Site\Config;
|
||||||
use Illuminate\Support\Str;
|
use Artisan;
|
||||||
|
use Cache;
|
||||||
|
use DB;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
trait AdminSettingsController
|
trait AdminSettingsController
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@ trait AdminSettingsController
|
||||||
$openReg = (bool) config_cache('pixelfed.open_registration');
|
$openReg = (bool) config_cache('pixelfed.open_registration');
|
||||||
$curOnboarding = (bool) config_cache('instance.curated_registration.enabled');
|
$curOnboarding = (bool) config_cache('instance.curated_registration.enabled');
|
||||||
$regState = $openReg ? 'open' : ($curOnboarding ? 'filtered' : 'closed');
|
$regState = $openReg ? 'open' : ($curOnboarding ? 'filtered' : 'closed');
|
||||||
|
$accountMigration = (bool) config_cache('federation.migration');
|
||||||
|
|
||||||
return view('admin.settings.home', compact(
|
return view('admin.settings.home', compact(
|
||||||
'jpeg',
|
'jpeg',
|
||||||
|
@ -48,7 +49,8 @@ trait AdminSettingsController
|
||||||
'cloud_ready',
|
'cloud_ready',
|
||||||
'availableAdmins',
|
'availableAdmins',
|
||||||
'currentAdmin',
|
'currentAdmin',
|
||||||
'regState'
|
'regState',
|
||||||
|
'accountMigration'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +69,8 @@ trait AdminSettingsController
|
||||||
'type_mp4' => 'nullable',
|
'type_mp4' => 'nullable',
|
||||||
'type_webp' => 'nullable',
|
'type_webp' => 'nullable',
|
||||||
'admin_account_id' => 'nullable',
|
'admin_account_id' => 'nullable',
|
||||||
'regs' => 'required|in:open,filtered,closed'
|
'regs' => 'required|in:open,filtered,closed',
|
||||||
|
'account_migration' => 'nullable',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$orb = false;
|
$orb = false;
|
||||||
|
@ -109,6 +112,7 @@ trait AdminSettingsController
|
||||||
ConfigCacheService::put('app.rules', $json);
|
ConfigCacheService::put('app.rules', $json);
|
||||||
Cache::forget('api:v1:instance-data:rules');
|
Cache::forget('api:v1:instance-data:rules');
|
||||||
Cache::forget('api:v1:instance-data-response-v1');
|
Cache::forget('api:v1:instance-data-response-v1');
|
||||||
|
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +151,7 @@ trait AdminSettingsController
|
||||||
'account_limit' => 'pixelfed.max_account_size',
|
'account_limit' => 'pixelfed.max_account_size',
|
||||||
'custom_css' => 'uikit.custom.css',
|
'custom_css' => 'uikit.custom.css',
|
||||||
'custom_js' => 'uikit.custom.js',
|
'custom_js' => 'uikit.custom.js',
|
||||||
'about_title' => 'about.title'
|
'about_title' => 'about.title',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($keys as $key => $value) {
|
foreach ($keys as $key => $value) {
|
||||||
|
@ -175,6 +179,7 @@ trait AdminSettingsController
|
||||||
'account_autofollow' => 'account.autofollow',
|
'account_autofollow' => 'account.autofollow',
|
||||||
'show_directory' => 'instance.landing.show_directory',
|
'show_directory' => 'instance.landing.show_directory',
|
||||||
'show_explore_feed' => 'instance.landing.show_explore',
|
'show_explore_feed' => 'instance.landing.show_explore',
|
||||||
|
'account_migration' => 'federation.migration',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($bools as $key => $value) {
|
foreach ($bools as $key => $value) {
|
||||||
|
@ -236,6 +241,7 @@ trait AdminSettingsController
|
||||||
{
|
{
|
||||||
$path = storage_path('app/'.config('app.name'));
|
$path = storage_path('app/'.config('app.name'));
|
||||||
$files = is_dir($path) ? new \DirectoryIterator($path) : [];
|
$files = is_dir($path) ? new \DirectoryIterator($path) : [];
|
||||||
|
|
||||||
return view('admin.settings.backups', compact('files'));
|
return view('admin.settings.backups', compact('files'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +253,7 @@ trait AdminSettingsController
|
||||||
public function settingsStorage(Request $request)
|
public function settingsStorage(Request $request)
|
||||||
{
|
{
|
||||||
$storage = [];
|
$storage = [];
|
||||||
|
|
||||||
return view('admin.settings.storage', compact('storage'));
|
return view('admin.settings.storage', compact('storage'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +265,7 @@ trait AdminSettingsController
|
||||||
public function settingsPages(Request $request)
|
public function settingsPages(Request $request)
|
||||||
{
|
{
|
||||||
$pages = Page::orderByDesc('updated_at')->paginate(10);
|
$pages = Page::orderByDesc('updated_at')->paginate(10);
|
||||||
|
|
||||||
return view('admin.pages.home', compact('pages'));
|
return view('admin.pages.home', compact('pages'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +287,7 @@ trait AdminSettingsController
|
||||||
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
||||||
$sys['database'] = [
|
$sys['database'] = [
|
||||||
'name' => 'Postgres',
|
'name' => 'Postgres',
|
||||||
'version' => explode(' ', DB::select($expQuery)[0]->version)[1]
|
'version' => explode(' ', DB::select($expQuery)[0]->version)[1],
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -288,17 +296,18 @@ trait AdminSettingsController
|
||||||
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
||||||
$sys['database'] = [
|
$sys['database'] = [
|
||||||
'name' => 'MySQL',
|
'name' => 'MySQL',
|
||||||
'version' => DB::select($expQuery)[0]->{'version()'}
|
'version' => DB::select($expQuery)[0]->{'version()'},
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$sys['database'] = [
|
$sys['database'] = [
|
||||||
'name' => 'Unknown',
|
'name' => 'Unknown',
|
||||||
'version' => '?'
|
'version' => '?',
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('admin.settings.system', compact('sys'));
|
return view('admin.settings.system', compact('sys'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ class ProfileMigrationController extends Controller
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
abort_if((bool) config_cache('federation.activitypub.enabled') === false, 404);
|
abort_if((bool) config_cache('federation.activitypub.enabled') === false, 404);
|
||||||
|
if ((bool) config_cache('federation.migration') === false) {
|
||||||
|
return redirect(route('help.account-migration'));
|
||||||
|
}
|
||||||
$hasExistingMigration = ProfileMigration::whereProfileId($request->user()->profile_id)
|
$hasExistingMigration = ProfileMigration::whereProfileId($request->user()->profile_id)
|
||||||
->where('created_at', '>', now()->subDays(30))
|
->where('created_at', '>', now()->subDays(30))
|
||||||
->exists();
|
->exists();
|
||||||
|
|
|
@ -15,6 +15,10 @@ class ProfileMigrationStoreRequest extends FormRequest
|
||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
|
if ((bool) config_cache('federation.activitypub.enabled') === false ||
|
||||||
|
(bool) config_cache('federation.migration') === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (! $this->user() || $this->user()->status) {
|
if (! $this->user() || $this->user()->status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use Cache;
|
|
||||||
use Config;
|
|
||||||
use App\Models\ConfigCache as ConfigCacheModel;
|
use App\Models\ConfigCache as ConfigCacheModel;
|
||||||
|
use Cache;
|
||||||
|
|
||||||
class ConfigCacheService
|
class ConfigCacheService
|
||||||
{
|
{
|
||||||
|
@ -74,6 +73,8 @@ class ConfigCacheService
|
||||||
'autospam.nlp.enabled',
|
'autospam.nlp.enabled',
|
||||||
|
|
||||||
'instance.curated_registration.enabled',
|
'instance.curated_registration.enabled',
|
||||||
|
|
||||||
|
'federation.migration',
|
||||||
// 'system.user_mode'
|
// 'system.user_mode'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -113,6 +114,7 @@ class ConfigCacheService
|
||||||
$exists->v = $val;
|
$exists->v = $val;
|
||||||
$exists->save();
|
$exists->save();
|
||||||
Cache::put(self::CACHE_KEY.$key, $val, now()->addHours(12));
|
Cache::put(self::CACHE_KEY.$key, $val, now()->addHours(12));
|
||||||
|
|
||||||
return self::get($key);
|
return self::get($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,4 +57,6 @@ return [
|
||||||
// max size in bytes, default is 2mb
|
// max size in bytes, default is 2mb
|
||||||
'max_size' => env('CUSTOM_EMOJI_MAX_SIZE', 2000000),
|
'max_size' => env('CUSTOM_EMOJI_MAX_SIZE', 2000000),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'migration' => env('PF_ACCT_MIGRATION_ENABLED', true),
|
||||||
];
|
];
|
||||||
|
|
|
@ -103,6 +103,16 @@
|
||||||
</div>
|
</div>
|
||||||
<p class="mb-4 small">ActivityPub federation, compatible with Pixelfed, Mastodon and other projects.</p>
|
<p class="mb-4 small">ActivityPub federation, compatible with Pixelfed, Mastodon and other projects.</p>
|
||||||
|
|
||||||
|
<div class="custom-control custom-checkbox mt-2">
|
||||||
|
<input type="checkbox" name="account_migration" class="custom-control-input" id="ap_mig" {{(bool)config_cache('federation.migration') ? 'checked' : ''}} {{(bool) config_cache('federation.activitypub.enabled') ? '' : 'disabled="disabled"'}}>
|
||||||
|
<label class="custom-control-label font-weight-bold" for="ap_mig">Account Migration</label>
|
||||||
|
</div>
|
||||||
|
@if((bool) config_cache('federation.activitypub.enabled'))
|
||||||
|
<p class="mb-4 small">Allow local accounts to migrate to other local or remote accounts.</p>
|
||||||
|
@else
|
||||||
|
<p class="mb-4 small text-muted"><strong>ActivityPub Required</strong> Allow local accounts to migrate to other local or remote accounts.</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
{{-- <div class="custom-control custom-checkbox mt-2">
|
{{-- <div class="custom-control custom-checkbox mt-2">
|
||||||
<input type="checkbox" name="open_registration" class="custom-control-input" id="openReg" {{config_cache('pixelfed.open_registration') ? 'checked' : ''}}>
|
<input type="checkbox" name="open_registration" class="custom-control-input" id="openReg" {{config_cache('pixelfed.open_registration') ? 'checked' : ''}}>
|
||||||
<label class="custom-control-label font-weight-bold" for="openReg">Open Registrations</label>
|
<label class="custom-control-label font-weight-bold" for="openReg">Open Registrations</label>
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if((bool) config_cache('federation.activitypub.enabled'))
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="aliases" class="col-sm-3 col-form-label font-weight-bold">Account Aliases</label>
|
<label for="aliases" class="col-sm-3 col-form-label font-weight-bold">Account Aliases</label>
|
||||||
<div class="col-sm-9" id="aliases">
|
<div class="col-sm-9" id="aliases">
|
||||||
|
@ -96,6 +97,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if((bool) config_cache('federation.migration'))
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="aliases" class="col-sm-3 col-form-label font-weight-bold">Account Migrate</label>
|
<label for="aliases" class="col-sm-3 col-form-label font-weight-bold">Account Migrate</label>
|
||||||
<div class="col-sm-9" id="aliases">
|
<div class="col-sm-9" id="aliases">
|
||||||
|
@ -103,6 +105,8 @@
|
||||||
<p class="help-text text-muted small">To redirect this account to a different one (where supported).</p>
|
<p class="help-text text-muted small">To redirect this account to a different one (where supported).</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
@if(config_cache('pixelfed.enforce_account_limit'))
|
@if(config_cache('pixelfed.enforce_account_limit'))
|
||||||
<div class="pt-3">
|
<div class="pt-3">
|
||||||
<p class="font-weight-bold text-muted text-center">Storage Usage</p>
|
<p class="font-weight-bold text-muted text-center">Storage Usage</p>
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
@if($hasExistingMigration)
|
@if($hasExistingMigration)
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 mt-5">
|
<div class="col-12 mt-5">
|
||||||
<p class="lead mb-0 text-center">You have migrated your account already.</p>
|
<p class="lead text-center">You have migrated your account already.</p>
|
||||||
|
<p>You can only migrate your account once per 30 days. If you want to migrate your followers back to this account, follow this process in reverse.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
|
|
19
resources/views/site/help/account-migration.blade.php
Normal file
19
resources/views/site/help/account-migration.blade.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
@extends('site.help.partial.template', ['breadcrumb'=>'Account Migration'])
|
||||||
|
|
||||||
|
@section('section')
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
<h3 class="font-weight-bold">Account Migration</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
@if((bool) config_cache('federation.migration') === false)
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<p class="font-weight-bold mb-0">Account Migration is not available on this server.</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<p class="lead">Account Migration is a feature that allows users to move their account followers from one Pixelfed instance (server) to another.</p>
|
||||||
|
<p class="lead">This can be useful if a user wants to switch to a different instance due to preferences for its community, policies, or features.</p>
|
||||||
|
@endsection
|
|
@ -314,6 +314,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::view('parental-controls', 'site.help.parental-controls');
|
Route::view('parental-controls', 'site.help.parental-controls');
|
||||||
Route::view('email-confirmation-issues', 'site.help.email-confirmation-issues')->name('help.email-confirmation-issues');
|
Route::view('email-confirmation-issues', 'site.help.email-confirmation-issues')->name('help.email-confirmation-issues');
|
||||||
Route::view('curated-onboarding', 'site.help.curated-onboarding')->name('help.curated-onboarding');
|
Route::view('curated-onboarding', 'site.help.curated-onboarding')->name('help.curated-onboarding');
|
||||||
|
Route::view('account-migration', 'site.help.account-migration')->name('help.account-migration');
|
||||||
});
|
});
|
||||||
Route::get('newsroom/{year}/{month}/{slug}', 'NewsroomController@show');
|
Route::get('newsroom/{year}/{month}/{slug}', 'NewsroomController@show');
|
||||||
Route::get('newsroom/archive', 'NewsroomController@archive');
|
Route::get('newsroom/archive', 'NewsroomController@archive');
|
||||||
|
|
Loading…
Reference in a new issue