Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public function publish(Request $request) |
||
18 | { |
||
19 | if ($request->headers->get('webhook-signature') === null) { |
||
|
|||
20 | throw new BadRequestHttpException('Header not set'); |
||
21 | } |
||
22 | |||
23 | $signature = hash_hmac('sha1', $request->getContent(), config('storyblok.webhook_secret')); |
||
24 | |||
25 | if ($request->header('webhook-signature') === $signature) { |
||
26 | if (Cache::getStore() instanceof \Illuminate\Cache\TaggableStore) { |
||
27 | Cache::tags('storyblok')->flush(); |
||
28 | } else { |
||
29 | Cache::flush(); |
||
30 | } |
||
31 | |||
32 | return ['success' => true]; |
||
33 | } |
||
34 | |||
35 | throw new BadRequestHttpException('Signature has invalid format'); |
||
36 | } |
||
38 |