Remove deprecated routes/methods
This commit is contained in:
parent
186ba7f018
commit
da38b33a24
3 changed files with 1 additions and 200 deletions
|
@ -96,89 +96,6 @@ class BaseApiController extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function accounts(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$profile = Profile::findOrFail($id);
|
||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function accountFollowers(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$profile = Profile::findOrFail($id);
|
||||
$followers = $profile->followers;
|
||||
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function accountFollowing(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$profile = Profile::findOrFail($id);
|
||||
$following = $profile->following;
|
||||
$resource = new Fractal\Resource\Collection($following, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function accountStatuses(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$this->validate($request, [
|
||||
'only_media' => 'nullable',
|
||||
'pinned' => 'nullable',
|
||||
'exclude_replies' => 'nullable',
|
||||
'max_id' => 'nullable|integer|min:1',
|
||||
'since_id' => 'nullable|integer|min:1',
|
||||
'min_id' => 'nullable|integer|min:1',
|
||||
'limit' => 'nullable|integer|min:1|max:24'
|
||||
]);
|
||||
$limit = $request->limit ?? 20;
|
||||
$max_id = $request->max_id ?? false;
|
||||
$min_id = $request->min_id ?? false;
|
||||
$since_id = $request->since_id ?? false;
|
||||
$only_media = $request->only_media ?? false;
|
||||
$user = Auth::user();
|
||||
$account = Profile::whereNull('status')->findOrFail($id);
|
||||
$statuses = $account->statuses()->getQuery();
|
||||
if($only_media == true) {
|
||||
$statuses = $statuses
|
||||
->whereIn('scope', ['public','unlisted'])
|
||||
->whereHas('media')
|
||||
->whereNull('in_reply_to_id')
|
||||
->whereNull('reblog_of_id');
|
||||
}
|
||||
if($id == $account->id && !$max_id && !$min_id && !$since_id) {
|
||||
$statuses = $statuses->orderBy('id', 'desc')
|
||||
->paginate($limit);
|
||||
} else if($since_id) {
|
||||
$statuses = $statuses->where('id', '>', $since_id)
|
||||
->orderBy('id', 'DESC')
|
||||
->paginate($limit);
|
||||
} else if($min_id) {
|
||||
$statuses = $statuses->where('id', '>', $min_id)
|
||||
->orderBy('id', 'ASC')
|
||||
->paginate($limit);
|
||||
} else if($max_id) {
|
||||
$statuses = $statuses->where('id', '<', $max_id)
|
||||
->orderBy('id', 'DESC')
|
||||
->paginate($limit);
|
||||
} else {
|
||||
$statuses = $statuses->whereScope('public')->orderBy('id', 'desc')->paginate($limit);
|
||||
}
|
||||
$resource = new Fractal\Resource\Collection($statuses, new StatusTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function avatarUpdate(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
@ -215,21 +132,6 @@ class BaseApiController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function showTempMedia(Request $request, $profileId, $mediaId, $timestamp)
|
||||
{
|
||||
abort(400, 'Endpoint deprecated');
|
||||
}
|
||||
|
||||
public function uploadMedia(Request $request)
|
||||
{
|
||||
abort(400, 'Endpoint deprecated');
|
||||
}
|
||||
|
||||
public function deleteMedia(Request $request)
|
||||
{
|
||||
abort(400, 'Endpoint deprecated');
|
||||
}
|
||||
|
||||
public function verifyCredentials(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
@ -242,21 +144,6 @@ class BaseApiController extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function drafts(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$medias = Media::whereUserId($user->id)
|
||||
->whereNull('status_id')
|
||||
->latest()
|
||||
->take(13)
|
||||
->get();
|
||||
$resource = new Fractal\Resource\Collection($medias, new MediaDraftTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
public function accountLikes(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
|
|
@ -14,16 +14,9 @@ use Auth, Cache;
|
|||
use Illuminate\Support\Facades\Redis;
|
||||
use App\Util\Site\Config;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\SuggestionService;
|
||||
|
||||
class ApiController extends BaseApiController
|
||||
{
|
||||
// todo: deprecate and remove
|
||||
public function hydrateLikes(Request $request)
|
||||
{
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
public function siteConfiguration(Request $request)
|
||||
{
|
||||
return response()->json(Config::get());
|
||||
|
@ -31,79 +24,6 @@ class ApiController extends BaseApiController
|
|||
|
||||
public function userRecommendations(Request $request)
|
||||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
abort_if(!config('exp.rec'), 400);
|
||||
|
||||
$id = Auth::user()->profile->id;
|
||||
|
||||
$following = Cache::remember('profile:following:'.$id, now()->addHours(12), function() use ($id) {
|
||||
return Follower::whereProfileId($id)->pluck('following_id')->toArray();
|
||||
});
|
||||
array_push($following, $id);
|
||||
$ids = SuggestionService::get();
|
||||
$filters = UserFilter::whereUserId($id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereIn('filter_type', ['mute', 'block'])
|
||||
->pluck('filterable_id')->toArray();
|
||||
$following = array_merge($following, $filters);
|
||||
|
||||
$key = config('cache.prefix').':api:local:exp:rec:'.$id;
|
||||
$ttl = (int) Redis::ttl($key);
|
||||
|
||||
if($request->filled('refresh') == true && (290 > $ttl) == true) {
|
||||
Cache::forget('api:local:exp:rec:'.$id);
|
||||
}
|
||||
|
||||
$res = Cache::remember('api:local:exp:rec:'.$id, now()->addMinutes(5), function() use($id, $following, $ids) {
|
||||
return Profile::select(
|
||||
'id',
|
||||
'username'
|
||||
)
|
||||
->whereNotIn('id', $following)
|
||||
->whereIn('id', $ids)
|
||||
->whereIsPrivate(0)
|
||||
->whereNull('status')
|
||||
->whereNull('domain')
|
||||
->inRandomOrder()
|
||||
->take(3)
|
||||
->get()
|
||||
->map(function($item, $key) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'avatar' => $item->avatarUrl(),
|
||||
'username' => $item->username,
|
||||
'message' => 'Recommended for You'
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
return response()->json($res->all());
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
public function composeLocationSearch(Request $request)
|
||||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
$this->validate($request, [
|
||||
'q' => 'required|string|max:100'
|
||||
]);
|
||||
$q = filter_var($request->input('q'), FILTER_SANITIZE_STRING);
|
||||
$hash = hash('sha256', $q);
|
||||
$key = 'search:location:id:' . $hash;
|
||||
$places = Cache::remember($key, now()->addMinutes(15), function() use($q) {
|
||||
$q = '%' . $q . '%';
|
||||
return Place::where('name', 'like', $q)
|
||||
->take(80)
|
||||
->get()
|
||||
->map(function($r) {
|
||||
return [
|
||||
'id' => $r->id,
|
||||
'name' => $r->name,
|
||||
'country' => $r->country,
|
||||
'url' => $r->url()
|
||||
];
|
||||
});
|
||||
});
|
||||
return $places;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -211,9 +211,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('accounts/{id}', 'PublicApiController@account');
|
||||
Route::post('avatar/update', 'ApiController@avatarUpdate');
|
||||
Route::get('custom_emojis', 'Api\ApiV1Controller@customEmojis');
|
||||
Route::get('likes', 'ApiController@hydrateLikes');
|
||||
Route::post('media', 'ApiController@uploadMedia');
|
||||
Route::delete('media', 'ApiController@deleteMedia');
|
||||
Route::get('notifications', 'ApiController@notifications');
|
||||
Route::get('timelines/public', 'PublicApiController@publicTimelineApi');
|
||||
Route::get('timelines/home', 'PublicApiController@homeTimelineApi');
|
||||
|
@ -277,7 +274,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::post('collection/{id}/publish', 'CollectionController@publish');
|
||||
Route::get('profile/collections/{id}', 'CollectionController@getUserCollections');
|
||||
|
||||
Route::get('compose/location/search', 'ApiController@composeLocationSearch');
|
||||
Route::post('compose/tag/untagme', 'MediaTagController@untagProfile');
|
||||
});
|
||||
|
||||
|
@ -340,8 +336,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('auth/checkpoint', 'AccountController@twoFactorCheckpoint');
|
||||
Route::post('auth/checkpoint', 'AccountController@twoFactorVerify');
|
||||
|
||||
Route::get('media/preview/{profileId}/{mediaId}/{timestamp}', 'ApiController@showTempMedia')->name('temp-media');
|
||||
|
||||
Route::get('results', 'SearchController@results');
|
||||
Route::post('visibility', 'StatusController@toggleVisibility');
|
||||
|
||||
|
|
Loading…
Reference in a new issue