浏览代码

Update ApiV1Controller, fix followAccountById with firstOrCreate()

Daniel Supernault 2 年之前
父节点
当前提交
1d52ad0b27
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      app/Http/Controllers/Api/ApiV1Controller.php

+ 4 - 4
app/Http/Controllers/Api/ApiV1Controller.php

@@ -692,10 +692,10 @@ class ApiV1Controller extends Controller
 				(new FollowerController())->sendFollow($user->profile, $target);
 				(new FollowerController())->sendFollow($user->profile, $target);
 			}
 			}
 		} else {
 		} else {
-			$follower = new Follower();
-			$follower->profile_id = $user->profile_id;
-			$follower->following_id = $target->id;
-			$follower->save();
+			$follower = Follower::firstOrCreate([
+				'profile_id' => $user->profile_id,
+				'following_id' => $target->id
+			]);
 
 
 			if($remote == true && config('federation.activitypub.remoteFollow') == true) {
 			if($remote == true && config('federation.activitypub.remoteFollow') == true) {
 				(new FollowerController())->sendFollow($user->profile, $target);
 				(new FollowerController())->sendFollow($user->profile, $target);