mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Merge pull request #4820 from pixelfed/staging
Add Mutual Followers API endpoint
This commit is contained in:
commit
1c40762921
4 changed files with 223 additions and 198 deletions
|
@ -11,6 +11,7 @@
|
|||
- Experimental home feed ([#4752](https://github.com/pixelfed/pixelfed/pull/4752)) ([c39b9afb](https://github.com/pixelfed/pixelfed/commit/c39b9afb))
|
||||
- Added `app:hashtag-cached-count-update` command to update cached_count of hashtags and add to scheduler to run every 25 minutes past the hour ([1e31fee6](https://github.com/pixelfed/pixelfed/commit/1e31fee6))
|
||||
- Added `app:hashtag-related-generate` command to generate related hashtags ([176b4ed7](https://github.com/pixelfed/pixelfed/commit/176b4ed7))
|
||||
- Added Mutual Followers API endpoint ([33dbbe46](https://github.com/pixelfed/pixelfed/commit/33dbbe46))
|
||||
|
||||
### Federation
|
||||
- Update Privacy Settings, add support for Mastodon `indexable` search flag ([fc24630e](https://github.com/pixelfed/pixelfed/commit/fc24630e))
|
||||
|
@ -75,6 +76,7 @@
|
|||
- Update ComposeModal, fix missing alttext post state ([0a068119](https://github.com/pixelfed/pixelfed/commit/0a068119))
|
||||
- Update PhotoAlbumPresenter.vue, fix fullscreen mode ([822e9888](https://github.com/pixelfed/pixelfed/commit/822e9888))
|
||||
- Update Timeline.vue, improve CHT pagination ([9c43e7e2](https://github.com/pixelfed/pixelfed/commit/9c43e7e2))
|
||||
- Update HomeFeedPipeline, fix StatusService validation ([041c0135](https://github.com/pixelfed/pixelfed/commit/041c0135))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)
|
||||
|
|
|
@ -20,6 +20,7 @@ use App\StatusArchived;
|
|||
use App\User;
|
||||
use App\UserSetting;
|
||||
use App\Services\AccountService;
|
||||
use App\Services\FollowerService;
|
||||
use App\Services\StatusService;
|
||||
use App\Services\ProfileStatusService;
|
||||
use App\Services\LikeService;
|
||||
|
@ -897,4 +898,19 @@ class ApiV1Dot1Controller extends Controller
|
|||
|
||||
return [200];
|
||||
}
|
||||
|
||||
public function getMutualAccounts(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$account = AccountService::get($id, true);
|
||||
if(!$account || !isset($account['id'])) { return []; }
|
||||
$res = collect(FollowerService::mutualAccounts($request->user()->profile_id, $id))
|
||||
->map(function($accountId) {
|
||||
return AccountService::get($accountId, true);
|
||||
})
|
||||
->filter()
|
||||
->take(24)
|
||||
->values();
|
||||
return $this->json($res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ class FollowerService
|
|||
const FOLLOWING_KEY = 'pf:services:follow:following:id:';
|
||||
const FOLLOWERS_KEY = 'pf:services:follow:followers:id:';
|
||||
const FOLLOWERS_LOCAL_KEY = 'pf:services:follow:local-follower-ids:';
|
||||
const FOLLOWERS_INTER_KEY = 'pf:services:follow:followers:inter:id:';
|
||||
|
||||
public static function add($actor, $target, $refresh = true)
|
||||
{
|
||||
|
@ -205,6 +206,22 @@ class FollowerService
|
|||
});
|
||||
}
|
||||
|
||||
public static function mutualAccounts($actorId, $profileId)
|
||||
{
|
||||
if($actorId == $profileId) {
|
||||
return [];
|
||||
}
|
||||
$actorKey = self::FOLLOWING_KEY . $actorId;
|
||||
$profileKey = self::FOLLOWERS_KEY . $profileId;
|
||||
$key = self::FOLLOWERS_INTER_KEY . $actorId . ':' . $profileId;
|
||||
$res = Redis::zinterstore($key, [$actorKey, $profileKey]);
|
||||
if($res) {
|
||||
return Redis::zrange($key, 0, -1);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function delCache($id)
|
||||
{
|
||||
Redis::del(self::CACHE_KEY . $id);
|
||||
|
|
|
@ -111,12 +111,9 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
});
|
||||
|
||||
Route::group(['prefix' => 'v1.1'], function() use($middleware) {
|
||||
$reportMiddleware = $middleware;
|
||||
$reportMiddleware[] = DeprecatedEndpoint::class;
|
||||
Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($reportMiddleware);
|
||||
Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($middleware);
|
||||
|
||||
Route::group(['prefix' => 'accounts'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware($middleware);
|
||||
Route::delete('avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware);
|
||||
Route::get('{id}/posts', 'Api\ApiV1Dot1Controller@accountPosts')->middleware($middleware);
|
||||
|
@ -125,10 +122,10 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
Route::get('two-factor', 'Api\ApiV1Dot1Controller@accountTwoFactor')->middleware($middleware);
|
||||
Route::get('emails-from-pixelfed', 'Api\ApiV1Dot1Controller@accountEmailsFromPixelfed')->middleware($middleware);
|
||||
Route::get('apps-and-applications', 'Api\ApiV1Dot1Controller@accountApps')->middleware($middleware);
|
||||
Route::get('mutuals/{id}', 'Api\ApiV1Dot1Controller@getMutualAccounts')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'collections'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('accounts/{id}', 'CollectionController@getUserCollections')->middleware($middleware);
|
||||
Route::get('items/{id}', 'CollectionController@getItems')->middleware($middleware);
|
||||
Route::get('view/{id}', 'CollectionController@getCollection')->middleware($middleware);
|
||||
|
@ -139,7 +136,6 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
});
|
||||
|
||||
Route::group(['prefix' => 'direct'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('thread', 'DirectMessageController@thread')->middleware($middleware);
|
||||
Route::post('thread/send', 'DirectMessageController@create')->middleware($middleware);
|
||||
Route::delete('thread/message', 'DirectMessageController@delete')->middleware($middleware);
|
||||
|
@ -151,19 +147,16 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
});
|
||||
|
||||
Route::group(['prefix' => 'archive'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::post('add/{id}', 'Api\ApiV1Dot1Controller@archive')->middleware($middleware);
|
||||
Route::post('remove/{id}', 'Api\ApiV1Dot1Controller@unarchive')->middleware($middleware);
|
||||
Route::get('list', 'Api\ApiV1Dot1Controller@archivedPosts')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'places'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('posts/{id}/{slug}', 'Api\ApiV1Dot1Controller@placesById')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'stories'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('carousel', 'Stories\StoryApiV1Controller@carousel')->middleware($middleware);
|
||||
Route::post('add', 'Stories\StoryApiV1Controller@add')->middleware($middleware);
|
||||
Route::post('publish', 'Stories\StoryApiV1Controller@publish')->middleware($middleware);
|
||||
|
@ -173,20 +166,17 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
});
|
||||
|
||||
Route::group(['prefix' => 'compose'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('search/location', 'ComposeController@searchLocation')->middleware($middleware);
|
||||
Route::get('settings', 'ComposeController@composeSettings')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'discover'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('accounts/popular', 'Api\ApiV1Controller@discoverAccountsPopular')->middleware($middleware);
|
||||
Route::get('posts/trending', 'DiscoverController@trendingApi')->middleware($middleware);
|
||||
Route::get('posts/hashtags', 'DiscoverController@trendingHashtags')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'directory'], function () use($middleware) {
|
||||
$middleware[] = DeprecatedEndpoint::class;
|
||||
Route::get('listing', 'PixelfedDirectoryController@get');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue