From 379938c489fc771e1a91975e6162a5b27495a035 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Wed, 11 Oct 2023 00:12:11 +0700 Subject: [PATCH] remove redundant code in the send notification method --- common/helpers.php | 14 -------------- src/Services/NotificationService.php | 6 +++--- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/common/helpers.php b/common/helpers.php index 1cb6724..90119f6 100755 --- a/common/helpers.php +++ b/common/helpers.php @@ -2,20 +2,6 @@ use LbilTech\TelegramGitNotifier\Helpers\ConfigHelper; -if (!function_exists('tgn_urlencoded_message')) { - /** - * Urlencoded message - * - * @param string $message - * - * @return array|string|string[] - */ - function tgn_urlencoded_message(string $message): array|string - { - return str_replace(["\n"], ['%0A'], urlencode($message)); - } -} - if (!function_exists('tgn_singularity')) { /** * The reverse of pluralizing, returns the singular form of a word in a string. diff --git a/src/Services/NotificationService.php b/src/Services/NotificationService.php index 81056bc..dc85ef4 100644 --- a/src/Services/NotificationService.php +++ b/src/Services/NotificationService.php @@ -14,9 +14,9 @@ class NotificationService implements NotificationInterface { use ActionEventTrait; - protected mixed $payload; + public mixed $payload; - protected string $message = ''; + public string $message = ''; public string $platform = EventConstant::DEFAULT_PLATFORM; @@ -87,7 +87,7 @@ public function sendNotify(string $chatId, string $message = null): bool 'chat_id' => $chatId, 'disable_web_page_preview' => 1, 'parse_mode' => 'html', - 'text' => tgn_urlencoded_message($this->message) + 'text' => $this->message ]; $url = 'https://api.telegram.org/bot'