1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-24 08:44:02 +00:00

Add /api/v1/statuses/{id}/reblog endpoint

This commit is contained in:
Daniel Supernault 2019-09-29 00:36:02 -06:00
parent 0a20b8321b
commit 43cef28296
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 33 additions and 2 deletions

View file

@ -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);
}
}

View file

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