PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.42
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.42
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / Integrations / Slack / SlackNotificationActions.php

SlackNotificationActions.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 3.6.42, at app/Services/Integrations/Slack/SlackNotificationActions.php

60 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Services\Integrations\Slack;
4
5 use FluentForm\App\Helpers\Helper;
6 use FluentForm\Framework\Foundation\Application;
7
8 class SlackNotificationActions
9 {
10 protected $app = null;
11
12 public function __construct(Application $app)
13 {
14 $this->app = $app;
15 // add_filter('fluentform_notifying_async_slack', '__return_false');
16 }
17
18 public function register()
19 {
20 add_filter('fluentform_global_notification_active_types', function ($types) {
21 $isEnabled = Helper::isSlackEnabled();
22 if ($isEnabled) {
23 $types['slack'] = 'slack';
24 }
25 return $types;
26 });
27 add_action('fluentform_integration_notify_slack', array($this, 'notify'), 20, 4);
28 }
29
30 public function notify($feed, $formData, $entry, $form)
31 {
32 $isEnabled = Helper::isSlackEnabled();
33 if (!$isEnabled) {
34 return;
35 }
36 $response = Slack::handle($feed, $formData, $form, $entry);
37 if ($response['status'] === 'success') {
38 do_action('ff_log_data', [
39 'parent_source_id' => $form->id,
40 'source_type' => 'submission_item',
41 'source_id' => $entry->id,
42 'component' => 'slack',
43 'status' => 'success',
44 'title' => $feed['meta_key'],
45 'description' => 'Slack feed has been successfully initialed and pushed data'
46 ]);
47 } else {
48 do_action('ff_log_data', [
49 'parent_source_id' => $form->id,
50 'source_type' => 'submission_item',
51 'source_id' => $entry->id,
52 'component' => 'slack',
53 'status' => 'failed',
54 'title' => $feed['meta_key'],
55 'description' => $response['message']
56 ]);
57 }
58 }
59 }
60