mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 17:53:16 +00:00
Update ApiV1Controller, fix following/follower entities, use masto schema by default and update components accordingly
This commit is contained in:
parent
75ea715b02
commit
4716c280c5
4 changed files with 22 additions and 14 deletions
|
@ -471,6 +471,7 @@ class ApiV1Controller extends Controller
|
||||||
'limit' => 'sometimes|integer|min:1|max:80'
|
'limit' => 'sometimes|integer|min:1|max:80'
|
||||||
]);
|
]);
|
||||||
$limit = $request->input('limit', 10);
|
$limit = $request->input('limit', 10);
|
||||||
|
$napi = $request->has(self::PF_API_ENTITY_KEY);
|
||||||
|
|
||||||
if(intval($pid) !== intval($account['id'])) {
|
if(intval($pid) !== intval($account['id'])) {
|
||||||
if($account['locked']) {
|
if($account['locked']) {
|
||||||
|
@ -496,8 +497,8 @@ class ApiV1Controller extends Controller
|
||||||
->whereFollowingId($account['id'])
|
->whereFollowingId($account['id'])
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->simplePaginate($limit)
|
->simplePaginate($limit)
|
||||||
->map(function($follower) {
|
->map(function($follower) use($napi) {
|
||||||
return AccountService::getMastodon($follower->profile_id, true);
|
return $napi ? AccountService::get($follower->profile_id, true) : AccountService::getMastodon($follower->profile_id, true);
|
||||||
})
|
})
|
||||||
->filter(function($account) {
|
->filter(function($account) {
|
||||||
return $account && isset($account['id']);
|
return $account && isset($account['id']);
|
||||||
|
@ -531,8 +532,8 @@ class ApiV1Controller extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $paginator->map(function($follower) {
|
$res = $paginator->map(function($follower) use($napi) {
|
||||||
return AccountService::get($follower->profile_id, true);
|
return $napi ? AccountService::get($follower->profile_id, true) : AccountService::getMastodon($follower->profile_id, true);
|
||||||
})
|
})
|
||||||
->filter(function($account) {
|
->filter(function($account) {
|
||||||
return $account && isset($account['id']);
|
return $account && isset($account['id']);
|
||||||
|
@ -561,6 +562,7 @@ class ApiV1Controller extends Controller
|
||||||
'limit' => 'sometimes|integer|min:1|max:80'
|
'limit' => 'sometimes|integer|min:1|max:80'
|
||||||
]);
|
]);
|
||||||
$limit = $request->input('limit', 10);
|
$limit = $request->input('limit', 10);
|
||||||
|
$napi = $request->has(self::PF_API_ENTITY_KEY);
|
||||||
|
|
||||||
if(intval($pid) !== intval($account['id'])) {
|
if(intval($pid) !== intval($account['id'])) {
|
||||||
if($account['locked']) {
|
if($account['locked']) {
|
||||||
|
@ -587,8 +589,8 @@ class ApiV1Controller extends Controller
|
||||||
->whereProfileId($account['id'])
|
->whereProfileId($account['id'])
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->simplePaginate($limit)
|
->simplePaginate($limit)
|
||||||
->map(function($follower) {
|
->map(function($follower) use($napi) {
|
||||||
return AccountService::get($follower->following_id, true);
|
return $napi ? AccountService::get($follower->following_id, true) : AccountService::getMastodon($follower->following_id, true);
|
||||||
})
|
})
|
||||||
->filter(function($account) {
|
->filter(function($account) {
|
||||||
return $account && isset($account['id']);
|
return $account && isset($account['id']);
|
||||||
|
@ -621,8 +623,8 @@ class ApiV1Controller extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $paginator->map(function($follower) {
|
$res = $paginator->map(function($follower) use($napi) {
|
||||||
return AccountService::get($follower->following_id, true);
|
return $napi ? AccountService::get($follower->following_id, true) : AccountService::getMastodon($follower->following_id, true);
|
||||||
})
|
})
|
||||||
->filter(function($account) {
|
->filter(function($account) {
|
||||||
return $account && isset($account['id']);
|
return $account && isset($account['id']);
|
||||||
|
|
|
@ -131,7 +131,8 @@
|
||||||
fetchFollowers() {
|
fetchFollowers() {
|
||||||
axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
|
axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
|
||||||
params: {
|
params: {
|
||||||
cursor: this.cursor
|
cursor: this.cursor,
|
||||||
|
'_pe': 1
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if(!res.data.length) {
|
if(!res.data.length) {
|
||||||
|
|
|
@ -129,7 +129,8 @@
|
||||||
fetchFollowers() {
|
fetchFollowers() {
|
||||||
axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
|
axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
|
||||||
params: {
|
params: {
|
||||||
cursor: this.cursor
|
cursor: this.cursor,
|
||||||
|
'_pe': 1
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if(!res.data.length) {
|
if(!res.data.length) {
|
||||||
|
|
|
@ -1084,7 +1084,8 @@
|
||||||
axios.get('/api/v1/accounts/'+this.profileId+'/following', {
|
axios.get('/api/v1/accounts/'+this.profileId+'/following', {
|
||||||
params: {
|
params: {
|
||||||
cursor: this.followingCursor,
|
cursor: this.followingCursor,
|
||||||
limit: 40
|
limit: 40,
|
||||||
|
'_pe': 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
@ -1125,7 +1126,8 @@
|
||||||
axios.get('/api/v1/accounts/'+this.profileId+'/followers', {
|
axios.get('/api/v1/accounts/'+this.profileId+'/followers', {
|
||||||
params: {
|
params: {
|
||||||
cursor: this.followerCursor,
|
cursor: this.followerCursor,
|
||||||
limit: 40
|
limit: 40,
|
||||||
|
'_pe': 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
@ -1158,7 +1160,8 @@
|
||||||
axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
|
axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
|
||||||
params: {
|
params: {
|
||||||
cursor: this.followingCursor,
|
cursor: this.followingCursor,
|
||||||
limit: 40
|
limit: 40,
|
||||||
|
'_pe': 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
@ -1187,7 +1190,8 @@
|
||||||
axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
|
axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
|
||||||
params: {
|
params: {
|
||||||
cursor: this.followerCursor,
|
cursor: this.followerCursor,
|
||||||
limit: 40
|
limit: 40,
|
||||||
|
'_pe': 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|
Loading…
Reference in a new issue