1
0
Fork 0
forked from mirror/pixelfed

Update ApiV1Controller, add idempotency-key support to /api/v1/statuses endpoint

This commit is contained in:
Daniel Supernault 2023-05-23 00:46:57 -06:00
parent f452509e17
commit c54cdd3eb4
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -2786,6 +2786,13 @@ class ApiV1Controller extends Controller
'comments_disabled' => 'sometimes|boolean',
]);
if($request->hasHeader('idempotency-key')) {
$key = 'pf:api:v1:status:idempotency-key:' . $request->user()->id . ':' . hash('sha1', $request->header('idempotency-key'));
$exists = Cache::has($key);
abort_if($exists, 400, 'Duplicate idempotency key.');
Cache::put($key, 1, 3600);
}
if(config('costar.enabled') == true) {
$blockedKeywords = config('costar.keyword.block');
if($blockedKeywords !== null && $request->status) {