浏览代码

Update ApiV1Controller, fix following/follower entities, use masto schema by default and update components accordingly

Daniel Supernault 2 年之前
父节点
当前提交
4716c280c5

+ 10 - 8
app/Http/Controllers/Api/ApiV1Controller.php

@@ -471,6 +471,7 @@ class ApiV1Controller extends Controller
 			'limit' => 'sometimes|integer|min:1|max:80'
 		]);
 		$limit = $request->input('limit', 10);
+		$napi = $request->has(self::PF_API_ENTITY_KEY);
 
 		if(intval($pid) !== intval($account['id'])) {
 			if($account['locked']) {
@@ -496,8 +497,8 @@ class ApiV1Controller extends Controller
 				->whereFollowingId($account['id'])
 				->orderByDesc('id')
 				->simplePaginate($limit)
-				->map(function($follower) {
-					return AccountService::getMastodon($follower->profile_id, true);
+				->map(function($follower) use($napi) {
+					return $napi ? AccountService::get($follower->profile_id, true) : AccountService::getMastodon($follower->profile_id, true);
 				})
 				->filter(function($account) {
 					return $account && isset($account['id']);
@@ -531,8 +532,8 @@ class ApiV1Controller extends Controller
 			}
 		}
 
-		$res = $paginator->map(function($follower) {
-				return AccountService::get($follower->profile_id, true);
+		$res = $paginator->map(function($follower) use($napi) {
+				return $napi ? AccountService::get($follower->profile_id, true) : AccountService::getMastodon($follower->profile_id, true);
 			})
 			->filter(function($account) {
 				return $account && isset($account['id']);
@@ -561,6 +562,7 @@ class ApiV1Controller extends Controller
 			'limit' => 'sometimes|integer|min:1|max:80'
 		]);
 		$limit = $request->input('limit', 10);
+		$napi = $request->has(self::PF_API_ENTITY_KEY);
 
 		if(intval($pid) !== intval($account['id'])) {
 			if($account['locked']) {
@@ -587,8 +589,8 @@ class ApiV1Controller extends Controller
 				->whereProfileId($account['id'])
 				->orderByDesc('id')
 				->simplePaginate($limit)
-				->map(function($follower) {
-					return AccountService::get($follower->following_id, true);
+				->map(function($follower) use($napi) {
+					return $napi ? AccountService::get($follower->following_id, true) : AccountService::getMastodon($follower->following_id, true);
 				})
 				->filter(function($account) {
 					return $account && isset($account['id']);
@@ -621,8 +623,8 @@ class ApiV1Controller extends Controller
 			}
 		}
 
-		$res = $paginator->map(function($follower) {
-				return AccountService::get($follower->following_id, true);
+		$res = $paginator->map(function($follower) use($napi) {
+				return $napi ? AccountService::get($follower->following_id, true) : AccountService::getMastodon($follower->following_id, true);
 			})
 			->filter(function($account) {
 				return $account && isset($account['id']);

+ 2 - 1
resources/assets/components/partials/profile/ProfileFollowers.vue

@@ -131,7 +131,8 @@
 			fetchFollowers() {
 				axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
 					params: {
-						cursor: this.cursor
+						cursor: this.cursor,
+						'_pe': 1
 					}
 				}).then(res => {
 					if(!res.data.length) {

+ 2 - 1
resources/assets/components/partials/profile/ProfileFollowing.vue

@@ -129,7 +129,8 @@
 			fetchFollowers() {
 				axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
 					params: {
-						cursor: this.cursor
+						cursor: this.cursor,
+						'_pe': 1
 					}
 				}).then(res => {
 					if(!res.data.length) {

+ 8 - 4
resources/assets/js/components/Profile.vue

@@ -1084,7 +1084,8 @@
 					axios.get('/api/v1/accounts/'+this.profileId+'/following', {
 						params: {
 							cursor: this.followingCursor,
-							limit: 40
+							limit: 40,
+							'_pe': 1
 						}
 					})
 					.then(res => {
@@ -1125,7 +1126,8 @@
 					axios.get('/api/v1/accounts/'+this.profileId+'/followers', {
 						params: {
 							cursor: this.followerCursor,
-							limit: 40
+							limit: 40,
+							'_pe': 1
 						}
 					})
 					.then(res => {
@@ -1158,7 +1160,8 @@
 				axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
 					params: {
 						cursor: this.followingCursor,
-						limit: 40
+						limit: 40,
+						'_pe': 1
 					}
 				})
 				.then(res => {
@@ -1187,7 +1190,8 @@
 				axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
 					params: {
 						cursor: this.followerCursor,
-						limit: 40
+						limit: 40,
+						'_pe': 1
 					}
 				})
 				.then(res => {