Skip to content
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
2 changes: 1 addition & 1 deletion Extenders/FrontExtender.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function addPartsSelectionProcedure($partsSelectionId, $partsSelectionDat
}
} catch (\Throwable $e) {
// Якщо модуль PartsSelection не встановлений, просто ігноруємо помилку
if (strpos($e->getMessage(), 'PartsSelection') === false && strpos($e->getMessage(), 'class FrontExtender found') === false) {
if (!str_contains($e->getMessage(), 'PartsSelection') && !str_contains($e->getMessage(), 'class FrontExtender found')) {
error_log('TelegramNotifier: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine());
}
}
Expand Down
2 changes: 1 addition & 1 deletion Helpers/ExampleMessageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function getExampleCallbackMessage(): string

// Якщо метод не знайшов назву товару, додамо її вручну для прикладу
$escapedUrl = htmlspecialchars($exampleUrl, ENT_QUOTES, 'UTF-8');
if (strpos($formattedMessage, 'iPhone 15') === false && strpos($formattedMessage, $exampleUrl) !== false) {
if (!str_contains($formattedMessage, 'iPhone 15') && str_contains($formattedMessage, $exampleUrl)) {
$formattedMessage = str_replace(
"Сторінка: {$exampleUrl}",
"Сторінка: <a href=\"{$escapedUrl}\">iPhone 15</a>",
Expand Down
4 changes: 2 additions & 2 deletions Helpers/FormatterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ private function getPageTitleFromUrl(string $url): ?string
if ($page && !empty($page->name)) {
return $page->name;
}
} catch (\Exception $e) {
} catch (\Exception) {
// Якщо не вдалося отримати назву, повертаємо null
}

Expand Down Expand Up @@ -598,7 +598,7 @@ private function getEntityTitle(string $entityClass, string $url): ?string
$entity = $this->entityFactory->get($entityClass);
$item = $entity->cols(['name'])->get($url);
return $item->name ?? null;
} catch (\Exception $e) {
} catch (\Exception) {
return null;
}
}
Expand Down
4 changes: 1 addition & 3 deletions Helpers/TelegramCronHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ private function getTopProducts(int $limit): array
if ($key === 0 && $name === '') {
continue;
}
if (!isset($byProduct[$key])) {
$byProduct[$key] = ['name' => $name ?: 'ID ' . $key, 'amount' => 0];
}
$byProduct[$key] ??= ['name' => $name ?: 'ID ' . $key, 'amount' => 0];
$byProduct[$key]['amount'] += (int) ($p->amount ?? 1);
}

Expand Down
26 changes: 13 additions & 13 deletions Helpers/TelegramHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ class TelegramHelper
private Settings $settings;
private FormatterHelper $formatterHelper;

private const MAX_MESSAGE_LENGTH = 4096;
private const CURL_TIMEOUT = 10;
private const CURL_CONNECT_TIMEOUT = 5;
private const int MAX_MESSAGE_LENGTH = 4096;
private const int CURL_TIMEOUT = 10;
private const int CURL_CONNECT_TIMEOUT = 5;

private const SETTING_ORDER_NOTIFY = 'sviat__telegram_notifier__order_notify_enabled';
private const SETTING_COMMENT_NOTIFY = 'sviat__telegram_notifier__comment_notify_enabled';
private const SETTING_FEEDBACK_NOTIFY = 'sviat__telegram_notifier__feedback_notify_enabled';
private const SETTING_CALLBACK_NOTIFY = 'sviat__telegram_notifier__callback_notify_enabled';
private const SETTING_PAID_ORDER_NOTIFY = 'sviat__telegram_notifier__paid_order_notify_enabled';
private const SETTING_PAID_ORDER_MESSAGE_TYPE = 'sviat__telegram_notifier__paid_order_message_type';
private const SETTING_ORDER_STATS = 'sviat__telegram_notifier__order_stats_enabled';
private const SETTING_PARTS_SELECTION_NOTIFY = 'sviat__telegram_notifier__parts_selection_notify_enabled';
private const SETTING_BOT_TOKEN = 'sviat__telegram_notifier__bot_token';
private const SETTING_CHAT_ID = 'sviat__telegram_notifier__chat_id';
private const string SETTING_ORDER_NOTIFY = 'sviat__telegram_notifier__order_notify_enabled';
private const string SETTING_COMMENT_NOTIFY = 'sviat__telegram_notifier__comment_notify_enabled';
private const string SETTING_FEEDBACK_NOTIFY = 'sviat__telegram_notifier__feedback_notify_enabled';
private const string SETTING_CALLBACK_NOTIFY = 'sviat__telegram_notifier__callback_notify_enabled';
private const string SETTING_PAID_ORDER_NOTIFY = 'sviat__telegram_notifier__paid_order_notify_enabled';
private const string SETTING_PAID_ORDER_MESSAGE_TYPE = 'sviat__telegram_notifier__paid_order_message_type';
private const string SETTING_ORDER_STATS = 'sviat__telegram_notifier__order_stats_enabled';
private const string SETTING_PARTS_SELECTION_NOTIFY = 'sviat__telegram_notifier__parts_selection_notify_enabled';
private const string SETTING_BOT_TOKEN = 'sviat__telegram_notifier__bot_token';
private const string SETTING_CHAT_ID = 'sviat__telegram_notifier__chat_id';

public function __construct(
Settings $settings,
Expand Down
4 changes: 2 additions & 2 deletions Init/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public function init()
[FrontExtender::class, 'addPartsSelectionProcedure']
);
}
} catch (\Throwable $e) {
} catch (\Throwable) {
// Якщо модуль PartsSelection не встановлений, просто ігноруємо помилку
}

$this->registerSchedule(
(new Schedule([TelegramCronHelper::class, 'sendMonthlyOrderStats']))
new Schedule([TelegramCronHelper::class, 'sendMonthlyOrderStats'])
->name('Telegram: monthly order stats')
->time('0 9 1 * *')
->overlap(false)
Expand Down
2 changes: 1 addition & 1 deletion Init/module.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Okay": "4.5.3",
"version": "1.0.10",
"version": "1.0.11",
"moduleName": "Telegram сповіщення",
"vendor": {
"email": "devsviat@proton.me",
Expand Down
Loading