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

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

63 lines 1.5 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 if ($request->get('type') == 'url_verification') {
27 echo wp_kses_post($request->get('challenge'));
28 }
29
30 return (new SlackNotification())->processSlackEvent($request->get('event'));
31 }
32
33
34
35 /**
36 * verifyProVersion method will check if the pro version is installed or not
37 * @throws Exception
38 * @return boolean | Exception
39 */
40 private function verifyProVersion ()
41 {
42 if (!defined('FLUENTSUPPORTPRO')) {
43 throw new \Exception('Slack Integration requires pro version of Fluent Support', 400);
44 }
45
46 return true;
47 }
48
49 /**
50 * validateToken method will check if the token is valid or not
51 * @param string $token
52 * @throws Exception
53 * @return boolean | Exception
54 */
55 private function validateToken ($token)
56 {
57 if (\FluentSupportPro\App\Services\Integrations\Slack\SlackHelper::getWebhookToken() != $token) {
58 throw new \Exception('Bot Token could not be verified', 404);
59 }
60 return true;
61 }
62 }
63