summaryrefslogtreecommitdiff
path: root/Postman
diff options
context:
space:
mode:
Diffstat (limited to 'Postman')
-rw-r--r--Postman/Postman-Configuration/PostmanConfigurationController.php23
-rw-r--r--Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php19
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogService.php1
-rw-r--r--Postman/PostmanInputSanitizer.php3
-rw-r--r--Postman/PostmanOptions.php14
-rw-r--r--Postman/notifications/PostmanNotify.php22
6 files changed, 82 insertions, 0 deletions
diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php
index 6abb5e2..a74ae04 100644
--- a/Postman/Postman-Configuration/PostmanConfigurationController.php
+++ b/Postman/Postman-Configuration/PostmanConfigurationController.php
@@ -428,6 +428,29 @@ class PostmanConfigurationController {
</table>
</div>
+ <div id="use-chrome-extension">
+ <h2><?php _e( 'Push To Chrome Extension', Postman::TEXT_DOMAIN ); ?></h2>
+ <table class="form-table">
+ <tbody>
+ <tr>
+ <th scope="row"><?php _e( 'This is an extra notification to the selection above', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <input type="checkbox" id="notification_use_chrome" name="postman_options[notification_use_chrome]" value="">
+ <a target="_blank" class="" href="https://chrome.google.com/webstore/detail/npklmbkpbknkmbohdbpikeidiaekjoch">
+ <?php _e( 'You can download the chrome extensiom here.', Postman::TEXT_DOMAIN ); ?>
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e( 'Your UID as you see in the extension.', Postman::TEXT_DOMAIN ); ?></th>
+ <td>
+ <input type="password" id="notification_chrome_uid" name="postman_options[notification_chrome_uid]" value="">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+
<?php
print '</fieldset>';
diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
index ecd7ec3..6102d10 100644
--- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
+++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
@@ -213,6 +213,16 @@ class PostmanSettingsRegistry {
'slack_token_callback',
), PostmanAdminController::NOTIFICATIONS_SLACK_CRED, 'slack_credentials' );
+ add_settings_field( PostmanOptions::NOTIFICATION_USE_CHROME, _x( 'Push to chrome extension', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'notification_use_chrome_callback',
+ ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
+
+ add_settings_field( PostmanOptions::NOTIFICATION_CHROME_UID, _x( 'Chrome Extension UID', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array(
+ $this,
+ 'notification_chrome_uid_callback',
+ ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
+
}
}
@@ -415,6 +425,15 @@ class PostmanSettingsRegistry {
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
}
+ public function notification_use_chrome_callback() {
+ $value = $this->options->useChromeExtension();
+ printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_USE_CHROME, $value ? 'checked="checked"' : '' );
+ }
+
+ public function notification_chrome_uid_callback() {
+ printf( '<input type="password" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_CHROME_UID, $this->options->getNotificationChromeUid() );
+ }
+
public function pushover_user_callback() {
printf( '<input type="password" id="pushover_user" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PUSHOVER_USER, $this->options->getPushoverUser() );
}
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogService.php b/Postman/Postman-Email-Log/PostmanEmailLogService.php
index ebb2e54..103dcc1 100644
--- a/Postman/Postman-Email-Log/PostmanEmailLogService.php
+++ b/Postman/Postman-Email-Log/PostmanEmailLogService.php
@@ -182,6 +182,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
$notify = new PostmanNotify( $notifyer, $message );
$notify->send($message, $log);
+ $notify->push_to_chrome($log->statusMessage);
}
/**
diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php
index b17df30..9e1fa52 100644
--- a/Postman/PostmanInputSanitizer.php
+++ b/Postman/PostmanInputSanitizer.php
@@ -74,6 +74,9 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
$this->sanitizePassword( 'Pushover Token', PostmanOptions::PUSHOVER_TOKEN, $input, $new_input, $this->options->getPushoverToken() );
$this->sanitizePassword( 'Slack Token', PostmanOptions::SLACK_TOKEN, $input, $new_input, $this->options->getSlackToken() );
+ $this->sanitizeString( 'Push Chrome Extension', PostmanOptions::NOTIFICATION_USE_CHROME, $input, $new_input );
+ $this->sanitizePassword( 'Push Chrome Extension UID', PostmanOptions::NOTIFICATION_CHROME_UID, $input, $new_input, $this->options->getNotificationChromeUid() );
+
if ( $new_input [ PostmanOptions::CLIENT_ID ] != $this->options->getClientId() || $new_input [ PostmanOptions::CLIENT_SECRET ] != $this->options->getClientSecret() || $new_input [ PostmanOptions::HOSTNAME ] != $this->options->getHostname() ) {
$this->logger->debug( 'Recognized new Client ID' );
// the user entered a new client id and we should destroy the stored auth token
diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php
index 9c244bd..29ddbc6 100644
--- a/Postman/PostmanOptions.php
+++ b/Postman/PostmanOptions.php
@@ -106,6 +106,8 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
const TEMPORARY_DIRECTORY = 'tmp_dir';
const DISABLE_EMAIL_VALIDAITON = 'disable_email_validation';
const NOTIFICATION_SERVICE = 'notification_service';
+ const NOTIFICATION_USE_CHROME = 'notification_use_chrome';
+ const NOTIFICATION_CHROME_UID = 'notification_chrome_uid';
const PUSHOVER_USER = 'pushover_user';
const PUSHOVER_TOKEN = 'pushover_token';
const SLACK_TOKEN = 'slack_token';
@@ -341,6 +343,18 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
return base64_decode( $this->options [ PostmanOptions::SLACK_TOKEN ] );
}
}
+
+ public function useChromeExtension() {
+ if ( isset( $this->options [ PostmanOptions::NOTIFICATION_USE_CHROME ] ) ) {
+ return $this->options [ PostmanOptions::NOTIFICATION_USE_CHROME ];
+ }
+ }
+
+ public function getNotificationChromeUid() {
+ if ( isset( $this->options [ PostmanOptions::NOTIFICATION_CHROME_UID ] ) ) {
+ return base64_decode( $this->options [ PostmanOptions::NOTIFICATION_CHROME_UID ] );
+ }
+ }
public function getReplyTo() {
if ( isset( $this->options [ PostmanOptions::REPLY_TO ] ) ) {
diff --git a/Postman/notifications/PostmanNotify.php b/Postman/notifications/PostmanNotify.php
index 22ca56f..365d708 100644
--- a/Postman/notifications/PostmanNotify.php
+++ b/Postman/notifications/PostmanNotify.php
@@ -14,4 +14,26 @@ class PostmanNotify {
public function send( $message, $log ) {
$this->notify->send_message( $message );
}
+
+ public function push_to_chrome($message) {
+ $push_chrome = PostmanOptions::getInstance()->useChromeExtension();
+
+ if ( $push_chrome ) {
+ $uid = PostmanOptions::getInstance()->getNotificationChromeUid();
+
+ if ( empty( $uid ) ) {
+ return;
+ }
+
+ $url = 'https://postmansmtp.com/chrome/' . $uid;
+
+ $args = array(
+ 'body' => array(
+ 'message' => $message
+ )
+ );
+
+ $response = wp_remote_post( $url , $args );
+ }
+ }
} \ No newline at end of file