From 9ee07fb562c6f3eb7f64c0c726921154e62ec2d7 Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Sun, 2 Jul 2023 14:40:00 +0200 Subject: [PATCH] feat: improve telegram setup workflow (#6734) --- .../Controllers/TelegramWebhookController.php | 5 +- .../NotificationsIndexViewHelper.php | 2 +- lang/bn.json | 1 + lang/ca.json | 1 + lang/da.json | 1 + lang/de.json | 1 + lang/el.json | 1 + lang/es.json | 1 + lang/fr.json | 3 +- lang/he.json | 1 + lang/hi.json | 1 + lang/it.json | 1 + lang/ja.json | 1 + lang/ml.json | 1 + lang/nl.json | 1 + lang/no.json | 1 + lang/pa.json | 1 + lang/pl.json | 1 + lang/pt.json | 1 + lang/ro.json | 1 + lang/ru.json | 1 + lang/sv.json | 1 + lang/te.json | 1 + lang/tr.json | 1 + lang/ur.json | 1 + lang/vi.json | 1 + lang/zh.json | 1 + .../Notifications/Partials/Telegram.vue | 306 +++++++++--------- routes/web.php | 10 +- .../NotificationsIndexViewHelperTest.php | 5 +- 30 files changed, 193 insertions(+), 162 deletions(-) diff --git a/app/Domains/Settings/ManageNotificationChannels/Web/Controllers/TelegramWebhookController.php b/app/Domains/Settings/ManageNotificationChannels/Web/Controllers/TelegramWebhookController.php index afe8489e6e0..509e58d4233 100644 --- a/app/Domains/Settings/ManageNotificationChannels/Web/Controllers/TelegramWebhookController.php +++ b/app/Domains/Settings/ManageNotificationChannels/Web/Controllers/TelegramWebhookController.php @@ -29,12 +29,13 @@ public function store(Request $request) // check if the message matches the expected pattern. // if the message does not match the pattern, then we return a 202 response // so telegram will stop trying to send the message. - if (! Str::of($messageText)->test('/^\/start\s[A-Za-z0-9-]{36}$/')) { + $message = Str::of($messageText); + if (! $message->test('/^\/start\s[A-Za-z0-9-]{36}$/')) { return response('Accepted', 202); } // Cleanup the string - $verificationKey = Str::of($messageText)->remove('/start ')->rtrim(); + $verificationKey = $message->remove('/start ')->rtrim(); // Get Telegram ID from the request. $chatId = $request->message['chat']['id']; diff --git a/app/Domains/Settings/ManageNotificationChannels/Web/ViewHelpers/NotificationsIndexViewHelper.php b/app/Domains/Settings/ManageNotificationChannels/Web/ViewHelpers/NotificationsIndexViewHelper.php index c47929511c7..b3a1d88067a 100644 --- a/app/Domains/Settings/ManageNotificationChannels/Web/ViewHelpers/NotificationsIndexViewHelper.php +++ b/app/Domains/Settings/ManageNotificationChannels/Web/ViewHelpers/NotificationsIndexViewHelper.php @@ -28,7 +28,7 @@ public static function data(User $user): array 'emails' => $emailsCollection, 'telegram' => [ 'data' => $telegram ? self::dtoTelegram($telegram) : null, - 'telegram_env_variable_set' => config('services.telegram-bot-api.token'), + 'telegram_env_variable_set' => config('services.telegram-bot-api.token') !== null, ], 'url' => [ 'settings' => route('settings.index'), diff --git a/lang/bn.json b/lang/bn.json index 8a56f71f398..3509b5c025b 100644 --- a/lang/bn.json +++ b/lang/bn.json @@ -826,6 +826,7 @@ "Set as favorite": "প্রিয় হিসাবে সেট করুন", "Settings": "সেটিংস", "Settle": "মীমাংসা", + "Setup": "সেটআপ", "Setup Key": "সেটআপ কী", "Setup Key:": "সেটআপ কী:", "Setup Telegram": "টেলিগ্রাম সেটআপ করুন", diff --git a/lang/ca.json b/lang/ca.json index 76a4aa76730..e2217b09934 100644 --- a/lang/ca.json +++ b/lang/ca.json @@ -826,6 +826,7 @@ "Set as favorite": "Estableix com a favorit", "Settings": "Configuració", "Settle": "Resoldre", + "Setup": "Configuració", "Setup Key": "Clau de configuració", "Setup Key:": "Clau de configuració:", "Setup Telegram": "Configura Telegram", diff --git a/lang/da.json b/lang/da.json index 8e3f52f0237..b121f7afc47 100644 --- a/lang/da.json +++ b/lang/da.json @@ -826,6 +826,7 @@ "Set as favorite": "Indstil som favorit", "Settings": "Indstillinger", "Settle": "Afregne", + "Setup": "Opsætning", "Setup Key": "Opsætningsnøgle", "Setup Key:": "Opsætningsnøgle:", "Setup Telegram": "Opsætning af telegram", diff --git a/lang/de.json b/lang/de.json index 9a363d4170a..b178eaab1f2 100644 --- a/lang/de.json +++ b/lang/de.json @@ -826,6 +826,7 @@ "Set as favorite": "Als Favorit festlegen", "Settings": "Einstellungen", "Settle": "Abwickeln", + "Setup": "Aufstellen", "Setup Key": "Einrichtungsschlüssel", "Setup Key:": "Setup-Schlüssel:", "Setup Telegram": "Telegram einrichten", diff --git a/lang/el.json b/lang/el.json index 10a745d3fcc..392582d88f1 100644 --- a/lang/el.json +++ b/lang/el.json @@ -826,6 +826,7 @@ "Set as favorite": "Ορίστε ως αγαπημένο", "Settings": "Ρυθμίσεις", "Settle": "Εγκαθίσταμαι", + "Setup": "Ρύθμιση", "Setup Key": "Κλειδί ρύθμισης", "Setup Key:": "Κλειδί ρύθμισης:", "Setup Telegram": "Ρύθμιση Telegram", diff --git a/lang/es.json b/lang/es.json index 61ec95bb484..f60b58f9b94 100644 --- a/lang/es.json +++ b/lang/es.json @@ -826,6 +826,7 @@ "Set as favorite": "Establecer como favorito", "Settings": "Configuraciones", "Settle": "Pagar", + "Setup": "Configuración", "Setup Key": "Clave de configuración", "Setup Key:": "Clave de configuración:", "Setup Telegram": "Configurar Telegram", diff --git a/lang/fr.json b/lang/fr.json index a27c6ae049b..b9bf8535e06 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -826,6 +826,7 @@ "Set as favorite": "Définir comme favori", "Settings": "Paramètres", "Settle": "Régler", + "Setup": "Configurer", "Setup Key": "Clé de configuration", "Setup Key:": "Clé de configuration :", "Setup Telegram": "Configurer Telegram", @@ -1277,4 +1278,4 @@ "😩 Awful": "😩 Horrible", "😶‍🌫️ Neutral": "😶‍🌫️ Neutre", "🥳 Awesome": "🥳 Génial" -} \ No newline at end of file +} diff --git a/lang/he.json b/lang/he.json index 34e64f16c95..494d20fc540 100644 --- a/lang/he.json +++ b/lang/he.json @@ -826,6 +826,7 @@ "Set as favorite": "הגדר כמועדף", "Settings": "הגדרות", "Settle": "לִשְׁקוֹעַ", + "Setup": "להכין", "Setup Key": "מפתח הגדרה", "Setup Key:": "מפתח הגדרה:", "Setup Telegram": "הגדרת טלגרם", diff --git a/lang/hi.json b/lang/hi.json index d0f72737706..9bb5f4559a4 100644 --- a/lang/hi.json +++ b/lang/hi.json @@ -826,6 +826,7 @@ "Set as favorite": "पसंदीदा के रूप में सेट करें", "Settings": "समायोजन", "Settle": "निपटारा करना", + "Setup": "स्थापित करना", "Setup Key": "सेटअप कुंजी", "Setup Key:": "सेटअप कुंजी:", "Setup Telegram": "सेटअप टेलीग्राम", diff --git a/lang/it.json b/lang/it.json index 1159ec1bfa8..91cff07a196 100644 --- a/lang/it.json +++ b/lang/it.json @@ -826,6 +826,7 @@ "Set as favorite": "Imposta come preferito", "Settings": "Impostazioni", "Settle": "Salda", + "Setup": "Impostare", "Setup Key": "Chiave di configurazione", "Setup Key:": "Chiave di configurazione:", "Setup Telegram": "Imposta Telegram", diff --git a/lang/ja.json b/lang/ja.json index 33444c13583..b1c213b2dcb 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -826,6 +826,7 @@ "Set as favorite": "お気に入りに設定", "Settings": "設定", "Settle": "解決", + "Setup": "設定", "Setup Key": "セットアップキー", "Setup Key:": "セットアップ キー:", "Setup Telegram": "テレグラムの設定", diff --git a/lang/ml.json b/lang/ml.json index 9fa25619da2..9e15b7cf328 100644 --- a/lang/ml.json +++ b/lang/ml.json @@ -826,6 +826,7 @@ "Set as favorite": "പ്രിയപ്പെട്ടതായി സജ്ജമാക്കുക", "Settings": "ക്രമീകരണങ്ങൾ", "Settle": "സെറ്റിൽ ചെയ്യുക", + "Setup": "സജ്ജമാക്കുക", "Setup Key": "സജ്ജീകരണ കീ", "Setup Key:": "സജ്ജീകരണ കീ:", "Setup Telegram": "ടെലിഗ്രാം സജ്ജീകരിക്കുക", diff --git a/lang/nl.json b/lang/nl.json index 1c6c8388882..870a68a43de 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -826,6 +826,7 @@ "Set as favorite": "Instellen als favoriet", "Settings": "Instellingen", "Settle": "Schikken", + "Setup": "Opgericht", "Setup Key": "Instelsleutel", "Setup Key:": "Instelsleutel:", "Setup Telegram": "Telegram instellen", diff --git a/lang/no.json b/lang/no.json index 9f8405e97fc..19baefa21e0 100644 --- a/lang/no.json +++ b/lang/no.json @@ -826,6 +826,7 @@ "Set as favorite": "Sett som favoritt", "Settings": "Innstillinger", "Settle": "Avgjøre", + "Setup": "Oppsett", "Setup Key": "Oppsettnøkkel", "Setup Key:": "Oppsettnøkkel:", "Setup Telegram": "Sett opp telegram", diff --git a/lang/pa.json b/lang/pa.json index 269b0d52bee..08c373d2fa5 100644 --- a/lang/pa.json +++ b/lang/pa.json @@ -826,6 +826,7 @@ "Set as favorite": "ਮਨਪਸੰਦ ਵਜੋਂ ਸੈੱਟ ਕਰੋ", "Settings": "ਸੈਟਿੰਗਾਂ", "Settle": "ਸੈਟਲ", + "Setup": "ਸਥਾਪਨਾ ਕਰਨਾ", "Setup Key": "ਸੈੱਟਅੱਪ ਕੁੰਜੀ", "Setup Key:": "ਸੈੱਟਅੱਪ ਕੁੰਜੀ:", "Setup Telegram": "ਟੈਲੀਗ੍ਰਾਮ ਸੈੱਟਅੱਪ ਕਰੋ", diff --git a/lang/pl.json b/lang/pl.json index a34430faf6d..944f00c39f9 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -826,6 +826,7 @@ "Set as favorite": "Ustaw jako ulubione", "Settings": "Ustawienia", "Settle": "Rozstrzygnąć", + "Setup": "Organizować coś", "Setup Key": "Klucz konfiguracji", "Setup Key:": "Klucz konfiguracji:", "Setup Telegram": "Ustaw telegram", diff --git a/lang/pt.json b/lang/pt.json index c6c83bdc8f8..4a799a93803 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -826,6 +826,7 @@ "Set as favorite": "Definir como favorito", "Settings": "Configurações", "Settle": "Quitar", + "Setup": "Configurar", "Setup Key": "Chave de configuração", "Setup Key:": "Chave de configuração:", "Setup Telegram": "Configurar Telegram", diff --git a/lang/ro.json b/lang/ro.json index cb22a49fb69..00d40373a51 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -826,6 +826,7 @@ "Set as favorite": "Setați ca favorit", "Settings": "Setări", "Settle": "Așează-te", + "Setup": "Înființat", "Setup Key": "Cheie de configurare", "Setup Key:": "Cheie de configurare:", "Setup Telegram": "Configurați Telegram", diff --git a/lang/ru.json b/lang/ru.json index a68e47f3820..23bbf98a989 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -826,6 +826,7 @@ "Set as favorite": "Установить в избранное", "Settings": "Настройки", "Settle": "Расселиться", + "Setup": "Настраивать", "Setup Key": "Ключ настройки", "Setup Key:": "Установка ключа:", "Setup Telegram": "Настройка Telegram", diff --git a/lang/sv.json b/lang/sv.json index 5cf7d07b7c8..8432b7a54db 100644 --- a/lang/sv.json +++ b/lang/sv.json @@ -826,6 +826,7 @@ "Set as favorite": "Ställ in som favorit", "Settings": "inställningar", "Settle": "Bosätta sig", + "Setup": "Uppstart", "Setup Key": "Inställningsnyckel", "Setup Key:": "Inställningsnyckel:", "Setup Telegram": "Ställ in telegram", diff --git a/lang/te.json b/lang/te.json index e25a84bf15a..18898b2bf14 100644 --- a/lang/te.json +++ b/lang/te.json @@ -826,6 +826,7 @@ "Set as favorite": "ఇష్టమైనదిగా సెట్ చేయండి", "Settings": "సెట్టింగ్‌లు", "Settle": "తేల్చుకో", + "Setup": "సెటప్", "Setup Key": "సెటప్ కీ", "Setup Key:": "సెటప్ కీ:", "Setup Telegram": "టెలిగ్రామ్‌ని సెటప్ చేయండి", diff --git a/lang/tr.json b/lang/tr.json index 3761f49c4ed..789371940dc 100644 --- a/lang/tr.json +++ b/lang/tr.json @@ -826,6 +826,7 @@ "Set as favorite": "Favori olarak ayarla", "Settings": "Ayarlar", "Settle": "Yerleşmek", + "Setup": "Kurmak", "Setup Key": "Kurulum Anahtarı", "Setup Key:": "Kurulum Anahtarı:", "Setup Telegram": "Telgrafı Kur", diff --git a/lang/ur.json b/lang/ur.json index 30fdc4d338b..39989c03c1e 100644 --- a/lang/ur.json +++ b/lang/ur.json @@ -826,6 +826,7 @@ "Set as favorite": "پسندیدہ کے طور پر سیٹ کریں۔", "Settings": "ترتیبات", "Settle": "آباد کرنا", + "Setup": "سیٹ اپ", "Setup Key": "سیٹ اپ کلید", "Setup Key:": "سیٹ اپ کلید:", "Setup Telegram": "ٹیلیگرام سیٹ اپ کریں۔", diff --git a/lang/vi.json b/lang/vi.json index db6f795201b..b76d4b1cb30 100644 --- a/lang/vi.json +++ b/lang/vi.json @@ -826,6 +826,7 @@ "Set as favorite": "Đặt làm mục yêu thích", "Settings": "Cài đặt", "Settle": "Ổn định", + "Setup": "Cài đặt", "Setup Key": "Khóa cài đặt", "Setup Key:": "Khóa cài đặt:", "Setup Telegram": "Thiết lập Telegram", diff --git a/lang/zh.json b/lang/zh.json index 07eab83e96d..bb05540172a 100644 --- a/lang/zh.json +++ b/lang/zh.json @@ -827,6 +827,7 @@ "Set as favorite": "设为收藏夹", "Settings": "设置", "Settle": "定居", + "Setup": "设置", "Setup Key": "设置键", "Setup Key:": "设置键:", "Setup Telegram": "设置电报", diff --git a/resources/js/Pages/Settings/Notifications/Partials/Telegram.vue b/resources/js/Pages/Settings/Notifications/Partials/Telegram.vue index 6b012d21740..686074ddc4f 100644 --- a/resources/js/Pages/Settings/Notifications/Partials/Telegram.vue +++ b/resources/js/Pages/Settings/Notifications/Partials/Telegram.vue @@ -1,3 +1,124 @@ + + - -