@@ -30,27 +30,33 @@ public function __construct()
3030 * Handle send notify to telegram action
3131 *
3232 * @return void
33+ * @throws GuzzleException
3334 */
3435 public function __invoke (): void
3536 {
3637 $ this ->telegramService ->checkCallback ();
3738 $ chatMessageId = $ this ->telegramService ->messageData ['message ' ]['chat ' ]['id ' ] ?? '' ;
3839
39- // Send a result to only the bot owner
40- if (!empty ($ chatMessageId ) && $ chatMessageId == $ this ->telegramService ->chatId ) {
41- $ this ->telegramService ->telegramToolHandler ($ this ->telegramService ->messageData ['message ' ]['text ' ]);
42- return ;
40+ if (!empty ($ chatMessageId )) {
41+ // Send a result to only the bot owner
42+ if ($ chatMessageId == $ this ->telegramService ->chatId ) {
43+ $ this ->telegramService ->telegramToolHandler ($ this ->telegramService ->messageData ['message ' ]['text ' ]);
44+ return ;
45+ }
46+
47+ // Notify access denied to other chat ids
48+ if (!in_array ($ chatMessageId , $ this ->chatIds )) {
49+ $ this ->notificationService ->accessDenied ($ this ->telegramService );
50+ return ;
51+ }
4352 }
4453
4554 // Send a result to all chat ids in config
46- try {
55+ if (! is_null ( $ this -> request -> server -> get ( ' HTTP_X_GITHUB_EVENT ' )) && empty ( $ chatMessageId )) {
4756 $ this ->notificationService ->setPayload ($ this ->request );
4857 foreach ($ this ->chatIds as $ chatId ) {
4958 $ this ->notificationService ->sendNotify ($ chatId );
5059 }
51- } catch (GuzzleException $ e ) {
52- error_log ($ e ->getMessage ());
53- $ this ->notificationService ->accessDenied ($ this ->telegramService ); // Notify access denied to other chat ids
5460 }
5561 }
5662}
0 commit comments