Skip to content

Commit f00ad7d

Browse files
committed
Fixed #22
1 parent b63a23c commit f00ad7d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
- Webhook URLs can now be set to environment variables or Twig code. ([#18](https://github.com/craftcms/webhooks/issues/18))
77
- Webhooks can now send PUT requests. ([#21](https://github.com/craftcms/webhooks/issues/21))
88

9+
### Fixed
10+
- Fixed a bug where webhooks would lose their custom payload template when enabled or disabled from the Manage Webhooks page. ([#22](https://github.com/craftcms/webhooks/issues/22))
11+
912
## 2.2.0 - 2019-07-29
1013

1114
### Added

src/controllers/WebhooksController.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,19 @@ public function actionSave()
128128
}
129129

130130
$attributes = $request->getBodyParams();
131-
if (ArrayHelper::remove($attributes, 'customPayload')) {
132-
$attributes['userAttributes'] = null;
133-
$attributes['senderAttributes'] = null;
134-
$attributes['eventAttributes'] = null;
135-
136-
if (empty($attributes['payloadTemplate'])) {
137-
$attributes['payloadTemplate'] = '{}';
131+
$customPayload = ArrayHelper::remove($attributes, 'customPayload');
132+
if ($customPayload !== null) {
133+
if ($customPayload) {
134+
$attributes['userAttributes'] = null;
135+
$attributes['senderAttributes'] = null;
136+
$attributes['eventAttributes'] = null;
137+
138+
if (empty($attributes['payloadTemplate'])) {
139+
$attributes['payloadTemplate'] = '{}';
140+
}
141+
} else {
142+
$attributes['payloadTemplate'] = null;
138143
}
139-
} else {
140-
$attributes['payloadTemplate'] = null;
141144
}
142145
$webhook->setAttributes($attributes);
143146

0 commit comments

Comments
 (0)