PluginProbe
FluentSMTP – WP Mail SMTP Plugin with Amazon SES, SendGrid, Mailgun, Postmark, Cloudflare, toSend, Gmail and Any SMTP / trunk
FluentSMTP – WP Mail SMTP Plugin with Amazon SES, SendGrid, Mailgun, Postmark, Cloudflare, toSend, Gmail and Any SMTP vtrunk
2.4.0 trunk 1.0.1 1.1.0 1.1.1 1.2.0 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.71 2.2.72 2.2.73 2.2.80 2.2.81 All 32 releases
fluent-smtp / app / Http / Controllers / PushoverController.php

PushoverController.php in FluentSMTP – WP Mail SMTP Plugin with Amazon SES, SendGrid, Mailgun, Postmark, Cloudflare, toSend, Gmail and Any SMTP trunk, at app/Http/Controllers/PushoverController.php

86 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentMail\App\Http\Controllers;
4
5 use FluentMail\App\Models\Settings;
6 use FluentMail\App\Services\NotificationHelper;
7 use FluentMail\Includes\Request\Request;
8 use FluentMail\Includes\Support\Arr;
9
10 class PushoverController extends Controller
11 {
12 public function registerSite(Request $request)
13 {
14 $this->verify();
15
16 $formData = $request->get('settings', []);
17
18 if (empty($formData['api_token'])) {
19 return $this->sendError([
20 'message' => __('An API token is required.', 'fluent-smtp')
21 ], 422);
22 }
23
24 if (empty($formData['user_key'])) {
25 return $this->sendError([
26 'message' => __('A user key is required.', 'fluent-smtp')
27 ], 422);
28 }
29
30 NotificationHelper::updateChannelSettings('pushover', [
31 'status' => 'yes',
32 'api_token' => sanitize_text_field(Arr::get($formData, 'api_token')),
33 'user_key' => sanitize_text_field(Arr::get($formData, 'user_key')),
34 ]);
35
36 return $this->sendSuccess([
37 'message' => __('Settings saved.', 'fluent-smtp'),
38 ]);
39 }
40
41 public function sendTestMessage(Request $request)
42 {
43 $this->verify();
44
45 $settings = (new Settings())->notificationSettings();
46
47 if (Arr::get($settings, 'pushover.status') != 'yes') {
48 return $this->sendError([
49 'message' => __('Pushover notifications are not enabled.', 'fluent-smtp')
50 ], 422);
51 }
52
53 $result = NotificationHelper::sendTestPushoverMessage(
54 Arr::get($settings, 'pushover.api_token'),
55 Arr::get($settings, 'pushover.user_key')
56 );
57
58 if (is_wp_error($result)) {
59 return $this->sendError([
60 'message' => $result->get_error_message(),
61 'errors' => $result->get_error_data(),
62 ], 422);
63 }
64
65 return $this->sendSuccess([
66 'message' => __('Test message sent.', 'fluent-smtp'),
67 'server_response' => $result
68 ]);
69 }
70
71 public function disconnect()
72 {
73 $this->verify();
74
75 NotificationHelper::updateChannelSettings('pushover', [
76 'status' => 'no',
77 'api_token' => '',
78 'user_key' => ''
79 ]);
80
81 return $this->sendSuccess([
82 'message' => __('Pushover has been disconnected.', 'fluent-smtp')
83 ]);
84 }
85 }
86