[REGISTER] Add self follow when registering, fixing the '-1 followers' bug

This commit is contained in:
Hugo Sales 2020-10-11 20:27:50 +00:00 committed by Hugo Sales
parent 089c710711
commit 0b759da780
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -6,6 +6,7 @@ use App\Core\Controller;
use App\Core\DB\DB;
use App\Core\Form;
use function App\Core\I18n\_m;
use App\Entity\Follow;
use App\Entity\GSActor;
use App\Entity\LocalUser;
use App\Security\Authenticator;
@ -84,8 +85,9 @@ class Security extends Controller
$actor = GSActor::create(['nickname' => $data['nickname']]);
DB::persist($actor);
DB::flush();
$id = $actor->getId();
$user = LocalUser::create([
'id' => $actor->getId(),
'id' => $id,
'nickname' => $data['nickname'],
'outgoing_email' => $data['email'],
'incoming_email' => $data['email'],
@ -108,6 +110,9 @@ class Security extends Controller
$user->setIsEmailVerified(true);
}
// Self follow
$follow = Follow::create(['follower' => $id, 'followed' => $id]);
DB::persist($follow);
DB::flush();
return $guard_handler->authenticateUserAndHandleSuccess(