Skip to content

Commit

Permalink
Merge pull request #13 from tanhongit/develop
Browse files Browse the repository at this point in the history
remove redundant code in the send notification method
  • Loading branch information
tanhongit authored Oct 10, 2023
2 parents 8e91af2 + 379938c commit 2688781
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
14 changes: 0 additions & 14 deletions common/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/Services/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 2688781

Please sign in to comment.