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

This commit is contained in:
Daniel Supernault 2023-03-05 01:03:34 -07:00
parent 75ea715b02
commit 4716c280c5
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
4 changed files with 22 additions and 14 deletions

View file

@ -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']);

View file

@ -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) {

View file

@ -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) {

View file

@ -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 => {