mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Add /api/v1/statuses/{id}/reblog endpoint
This commit is contained in:
parent
0a20b8321b
commit
43cef28296
2 changed files with 33 additions and 2 deletions
|
@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
|||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use App\Util\Media\Filter;
|
||||
use Laravel\Passport\Passport;
|
||||
use Auth, Cache, DB, URL;
|
||||
use App\{
|
||||
|
@ -33,7 +34,7 @@ use League\Fractal\Serializer\ArraySerializer;
|
|||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use App\Http\Controllers\StatusController;
|
||||
use App\Jobs\LikePipeline\LikePipeline;
|
||||
use App\Util\Media\Filter;
|
||||
use App\Jobs\SharePipeline\SharePipeline;
|
||||
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||
use App\Jobs\StatusPipeline\StatusDelete;
|
||||
use App\Jobs\FollowPipeline\FollowPipeline;
|
||||
|
@ -43,7 +44,6 @@ use App\Jobs\VideoPipeline\{
|
|||
VideoPostProcess,
|
||||
VideoThumbnail
|
||||
};
|
||||
|
||||
use App\Services\NotificationService;
|
||||
|
||||
class ApiV1Controller extends Controller
|
||||
|
@ -1582,4 +1582,33 @@ class ApiV1Controller extends Controller
|
|||
|
||||
return response()->json(['Status successfully deleted.']);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/v1/statuses/{id}/reblog
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return StatusTransformer
|
||||
*/
|
||||
public function statusShare(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$user = $request->user();
|
||||
$status = Status::findOrFail($id);
|
||||
|
||||
$share = Status::firstOrCreate([
|
||||
'profile_id' = $user->profile_id,
|
||||
'reblog_of_id' = $status->id,
|
||||
'in_reply_to_profile_id' = $status->profile_id
|
||||
]);
|
||||
|
||||
if($share->wasRecentlyCreated == true) {
|
||||
SharePipeline::dispatch($share);
|
||||
}
|
||||
|
||||
$resource = new Fractal\Resource\Item($share, new StatusTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
return response()->json($res);
|
||||
}
|
||||
}
|
|
@ -126,6 +126,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('conversations', 'Api\ApiV1Controller@conversations')->middleware('auth:api');
|
||||
Route::get('timelines/public', 'Api\ApiV1Controller@timelinePublic');
|
||||
Route::post('statuses', 'Api\ApiV1Controller@statusCreate')->middleware('auth:api');
|
||||
Route::delete('statuses/{id}', 'Api\ApiV1Controller@statusDelete')->middleware('auth:api');
|
||||
Route::post('statuses/{id}/reblog', 'Api\ApiV1Controller@statusShare')->middleware('auth:api');
|
||||
|
||||
// Route::get('likes', 'ApiController@hydrateLikes');
|
||||
// Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');
|
||||
|
|
Loading…
Reference in a new issue