Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove redundant code in the send notification method #13

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not need it with using the http_build_query function.

];

$url = 'https://api.telegram.org/bot'
Expand Down