PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.5
2.4.5 2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 All 69 releases
fluent-support / app / Services / ThirdParty / HandleSlackEvent.php

HandleSlackEvent.php in Fluent Support – Helpdesk & Customer Support Ticket System 2.4.5, at app/Services/ThirdParty/HandleSlackEvent.php

56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Services\ThirdParty;
4
5 use Exception;
6 use FluentSupport\App\App;
7 use FluentSupportPro\App\Services\Integrations\Slack\SlackNotification;
8
9 class HandleSlackEvent
10 {
11
12 /**
13 * @param string $token
14 * @return bool
15 * @throws Exception
16 */
17
18 public function handleEvent ( $token )
19 {
20 $this->verifyProVersion();
21 $this->validateToken($token);
22
23 $request = App::getInstance('request');
24
25 return (new SlackNotification())->processSlackEvent($request->get('event'));
26 }
27
28
29
30 /**
31 * @throws Exception
32 * @return bool
33 */
34 private function verifyProVersion ()
35 {
36 if (!defined('FLUENTSUPPORTPRO')) {
37 throw new \Exception('Slack Integration requires pro version of Fluent Support', 400);
38 }
39
40 return true;
41 }
42
43 /**
44 * @param string $token
45 * @throws Exception
46 * @return bool
47 */
48 private function validateToken ($token)
49 {
50 if (!hash_equals(\FluentSupportPro\App\Services\Integrations\Slack\SlackHelper::getWebhookToken(), $token)) {
51 throw new \Exception('Bot Token could not be verified', 403);
52 }
53 return true;
54 }
55 }
56