diff --git a/database/migrations/2022_09_01_000000_fix_webfinger_profile_duplicate_accounts.php b/database/migrations/2022_09_01_000000_fix_webfinger_profile_duplicate_accounts.php new file mode 100644 index 000000000..3a10c9d5f --- /dev/null +++ b/database/migrations/2022_09_01_000000_fix_webfinger_profile_duplicate_accounts.php @@ -0,0 +1,59 @@ +where('username', 'not like', '@%') + ->chunk(200, function($profiles) { + foreach($profiles as $profile) { + $exists = Profile::whereUsername("@{$profile->username}@{$profile->domain}")->first(); + if($exists) { + $exists->username = null; + $exists->domain = null; + $exists->webfinger = null; + $exists->save(); + DeleteRemoteProfilePipeline::dispatch($exists); + + $profile->username = "@{$profile->username}@{$profile->domain}"; + if(!$profile->webfinger) { + $profile->webfinger = "@{$profile->username}@{$profile->domain}"; + } + $profile->save(); + } else { + $profile->username = "@{$profile->username}@{$profile->domain}"; + if(!$profile->webfinger) { + $profile->webfinger = "@{$profile->username}@{$profile->domain}"; + } + $profile->save(); + } + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/migrations/2022_09_01_043002_generate_missing_profile_webfinger.php b/database/migrations/2022_09_01_043002_generate_missing_profile_webfinger.php new file mode 100644 index 000000000..55a0f9002 --- /dev/null +++ b/database/migrations/2022_09_01_043002_generate_missing_profile_webfinger.php @@ -0,0 +1,38 @@ +whereNull('webfinger') + ->chunk(200, function($profiles) { + foreach($profiles as $profile) { + if(substr($profile->username, 0, 1) === "@") { + $profile->webfinger = $profile->username; + $profile->save(); + } + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}