Skip to content

Commit f9c0691

Browse files
committed
attemptDelay → retryDelay
1 parent 1f2eaf8 commit f9c0691

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ The array can define the following keys:
5050

5151
- `maxDepth` – The maximum depth that the plugin should go into objects/arrays when converting them to arrays for event payloads. (Default is `5`.)
5252
- `maxAttempts` – The maximum number of attempts each webhook should have before giving up, if the requests are coming back with non 2xx responses. (Default is `1`.)
53-
- `attemptDelay` – The delay (in seconds) between webhook attempts. (Default is `60`.)
53+
- `retryDelay` – The delay (in seconds) between webhook attempts. (Default is `60`.)
5454

5555
## Managing Webhooks
5656

src/SendRequestJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function execute($queue)
6262
$settings = Plugin::getInstance()->getSettings();
6363
if ($attempts < $settings->maxAttempts) {
6464
Craft::$app->getQueue()
65-
->delay($settings->attemptDelay)
65+
->delay($settings->retryDelay)
6666
->push(new self([
6767
'requestId' => $this->requestId,
6868
]));

src/Settings.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace craft\webhooks;
44

55
use craft\base\Model;
6+
use craft\helpers\ArrayHelper;
67

78
class Settings extends Model
89
{
@@ -18,9 +19,23 @@ class Settings extends Model
1819
public $maxAttempts = 1;
1920

2021
/**
21-
* @var int The time delay in seconds between request attempts.
22+
* @var int The time delay in seconds between request retrys.
23+
* @since 2.3.0
2224
*/
23-
public $attemptDelay = 60;
25+
public $retryDelay = 60;
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public function setAttributes($values, $safeOnly = true)
31+
{
32+
// attemptDelay → retryDelay
33+
if (($retryDelay = ArrayHelper::remove($values, 'attemptDelay')) !== null) {
34+
$values['retryDelay'] = $retryDelay;
35+
}
36+
37+
parent::setAttributes($values, $safeOnly);
38+
}
2439

2540
/**
2641
* @inheritdoc

src/templates/_settings.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
{{ forms.textField({
2424
first: true,
25-
id: 'attempt-delay',
26-
label: 'Attempt Delay'|t('webhooks'),
25+
id: 'retry-delay',
26+
label: 'Retry Delay'|t('webhooks'),
2727
instructions: 'The time delay in seconds between request attempts.'|t('webhooks'),
2828
size: 5,
29-
name: 'attemptDelay',
30-
value: settings.attemptDelay,
29+
name: 'retryDelay',
30+
value: settings.retryDelay,
3131
}) }}

0 commit comments

Comments
 (0)