PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / trunk
Fluent Support – Helpdesk & Customer Support Ticket System vtrunk
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 1.5.5 All 68 releases
fluent-support / app / Services / ThirdParty / HandleSlackEvent.php

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

59 lines 1.4 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 * handleEvent method is responsible for handling slack events
14 * @param string $token
15 * @return bool
16 * @throws Exception
17 */
18
19 public function handleEvent ( $token )
20 {
21 $this->verifyProVersion();
22 $this->validateToken($token);
23
24 $request = App::getInstance('request');
25
26 return (new SlackNotification())->processSlackEvent($request->get('event'));
27 }
28
29
30
31 /**
32 * verifyProVersion method will check if the pro version is installed or not
33 * @throws Exception
34 * @return boolean | Exception
35 */
36 private function verifyProVersion ()
37 {
38 if (!defined('FLUENTSUPPORTPRO')) {
39 throw new \Exception('Slack Integration requires pro version of Fluent Support', 400);
40 }
41
42 return true;
43 }
44
45 /**
46 * validateToken method will check if the token is valid or not
47 * @param string $token
48 * @throws Exception
49 * @return boolean | Exception
50 */
51 private function validateToken ($token)
52 {
53 if (!hash_equals(\FluentSupportPro\App\Services\Integrations\Slack\SlackHelper::getWebhookToken(), $token)) {
54 throw new \Exception('Bot Token could not be verified', 403);
55 }
56 return true;
57 }
58 }
59