Skip to content

Commit

Permalink
Merge pull request #636 from defstudio/#635
Browse files Browse the repository at this point in the history
#635 implement config for connection request timeout
  • Loading branch information
fabio-ivona authored Sep 2, 2024
2 parents a3eb891 + 3fe86e1 commit 3d49150
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions config/telegraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
*/
'http_timeout' => env('TELEGRAPH_HTTP_TIMEOUT', 30),

/*
* Sets HTTP connection request timeout when interacting with Telegram servers
*/
'http_connection_timeout' => env('TELEGRAPH_HTTP_CONNECTION_TIMEOUT', 10),

'security' => [
/*
* if enabled, allows callback queries from unregistered chats
Expand Down
6 changes: 5 additions & 1 deletion docs/2.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ return [
* Sets HTTP request timeout when interacting with Telegram servers
*/
'http_timeout' => 30,


/*
* Sets HTTP connection request timeout when interacting with Telegram servers
*/
'http_connection_timeout' => 10,

'security' => [
/*
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/InteractsWithTelegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function ($request, Attachment $attachment, string $key) {
);

/** @phpstan-ignore-next-line */
return $request->timeout(config('telegraph.http_timeout', 30))->post($this->getApiUrl(), $this->prepareData());
return $request->timeout(config('telegraph.http_timeout', 30))->connectTimeout(config('telegraph.http_connection_timeout', 10))->post($this->getApiUrl(), $this->prepareData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function fromArray(array $data): Message

$message->id = $data['message_id'];

if(isset($data['message_thread_id'])) {
if (isset($data['message_thread_id'])) {
$message->messageThreadId = $data['message_thread_id'];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/SendRequestToTelegramJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ function ($request, Attachment $attachment, string $key) {
);

/** @phpstan-ignore-next-line */
$request->timeout(config('telegraph.http_timeout', 30))->post($this->url, $this->data);
$request->timeout(config('telegraph.http_timeout', 30))->connectTimeout(config('telegraph.http_connection_timeout', 10))->post($this->url, $this->data);
}
}

0 comments on commit 3d49150

Please sign in to comment.