Skip to content

Commit

Permalink
Merge pull request #30 from nguyenanhung/v3.x
Browse files Browse the repository at this point in the history
V3.x
  • Loading branch information
nguyenanhung authored Aug 15, 2023
2 parents f7efbbb + bef98f6 commit 9bde681
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
6 changes: 6 additions & 0 deletions helpers/system_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* Date: 2/12/20
* Time: 11:00
*/
if (!function_exists('_sn_helper_error_message_')) {
function _sn_helper_error_message_($e): string
{
return 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
}
}
if (!function_exists('system_notification_to_mantis')) {
/**
* Hàm gửi thông báo, cảnh báo hệ thống tới Mantis Bug Tracker
Expand Down
4 changes: 2 additions & 2 deletions src/ProjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
interface ProjectInterface
{
const VERSION = '3.0.7';
const LAST_MODIFIED = '2022-03-15';
const VERSION = '3.0.8';
const LAST_MODIFIED = '2022-08-15';
const AUTHOR_NAME = 'Hung Nguyen';
const AUTHOR_EMAIL = 'dev@nguyenanhung.com';
const PROJECT_NAME = 'Monitor Connector';
Expand Down
33 changes: 8 additions & 25 deletions src/SystemNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ public static function mantis(array $sdkConfig = array(), string $module = '', s
->setMonitorPassword($options['monitorPassword'])
->setProjectId($options['monitorProjectId'])
->mantis($monitorProjectName . $title . ' - ' . $module, $description);

return true;
}
} catch (Exception $e) {
if (function_exists('log_message')) {
log_message('error', 'Error Message: ' . $e->getMessage());
log_message('error', _sn_helper_error_message_($e));
log_message('error', 'Error Trace As String: ' . $e->getTraceAsString());
}
}

return false;
}

Expand Down Expand Up @@ -103,16 +101,14 @@ public static function slack(array $sdkConfig = array(), string $module = '', st
$handle->setAttachMessage($attachMessage);
}
$handle->send();

return true;
}
} catch (Exception $e) {
if (function_exists('log_message')) {
log_message('error', 'Error Message: ' . $e->getMessage());
log_message('error', _sn_helper_error_message_($e));
log_message('error', 'Error Trace As String: ' . $e->getTraceAsString());
}
}

return false;
}

Expand Down Expand Up @@ -143,20 +139,15 @@ public static function telegram(array $sdkConfig = array(), string $module = '',
$chatId = $config['default_chat_id'] ?? null;
}
$handle = new TelegramMessenger();
$handle->setSdkConfig($sdkConfig)
->setChatId($chatId)
->setMessage($message)
->sendMessage();

$handle->setSdkConfig($sdkConfig)->setChatId($chatId)->setMessage($message)->sendMessage();
return true;
}
} catch (Exception $e) {
if (function_exists('log_message')) {
log_message('error', 'Error Message: ' . $e->getMessage());
log_message('error', _sn_helper_error_message_($e));
log_message('error', 'Error Trace As String: ' . $e->getTraceAsString());
}
}

return false;
}

Expand Down Expand Up @@ -191,20 +182,15 @@ public static function google_chat(array $sdkConfig = array(), string $module =
$access_key = $config['access_key'] ?? null;
$access_token = $config['access_token'] ?? null;
$handle = new Notifier();
$handle->setSpaceId($chatId)
->setKey($access_key)
->setToken($access_token)
->setMessage($message);

$handle->setSpaceId($chatId)->setKey($access_key)->setToken($access_token)->setMessage($message);
return $handle->send();
}
} catch (Exception $e) {
if (function_exists('log_message')) {
log_message('error', 'Error Message: ' . $e->getMessage());
log_message('error', _sn_helper_error_message_($e));
log_message('error', 'Error Trace As String: ' . $e->getTraceAsString());
}
}

return false;
}

Expand Down Expand Up @@ -234,18 +220,15 @@ public static function teams(array $sdkConfig = array(), string $module = '', st
$title = $monitorProjectName . $module;
$textMessage = $message;
$teams = new MicrosoftTeamsConnector();
$teams->setWebHook($webhookUrl)
->simpleMessage($title, $textMessage);

$teams->setWebHook($webhookUrl)->simpleMessage($title, $textMessage);
return true;
}
} catch (Exception $e) {
if (function_exists('log_message')) {
log_message('error', 'Error Message: ' . $e->getMessage());
log_message('error', _sn_helper_error_message_($e));
log_message('error', 'Error Trace As String: ' . $e->getTraceAsString());
}
}

return false;
}
}

0 comments on commit 9bde681

Please sign in to comment.