Skip to content

Commit 0e4d885

Browse files
committed
Merge branch 'release/2.0.0'
2 parents 2e79419 + 27fb55f commit 0e4d885

32 files changed

+1275
-192
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
*.DS_Store
44
*Thumbs.db
55
/node_modules
6+
/vendor
7+
composer.lock

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Release Notes for Webhooks for Craft CMS
22

3+
## 2.0.0 - 2019-03-19
4+
5+
### Added
6+
- Webhooks now logs requests, and it’s possible to view them from a new “Activity” page within the plugin.
7+
- Added new `maxDepth`, `maxAttempts` and `attemptDelay` settings, which can be set from `config/webhooks.php`.
8+
- The Sender Class and Event Name webhook settings now show suggestions based on the available classes and events.
9+
- Webhooks can now have custom payloads. ([#3](https://github.com/craftcms/webhooks/pull/3))
10+
11+
### Changed
12+
- Webhooks now requires Craft 3.1 or later.
13+
314
## 1.1.2 - 2018-12-21
415

516
### Changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It can be used to integrate your Craft project with task automation tools like [
88

99
## Requirements
1010

11-
This plugin requires Craft CMS 3.0.0 or later.
11+
This plugin requires Craft CMS 3.1.19 or later.
1212

1313
## Installation
1414

@@ -33,6 +33,25 @@ composer require craftcms/webhooks
3333
./craft install/plugin webhooks
3434
```
3535

36+
## Configuration
37+
38+
To configure Webhooks, create a `config/webhooks.php` file, which returns an array.
39+
40+
```php
41+
<?php
42+
return [
43+
'maxDepth' => 10,
44+
'maxAttempts' => 3,
45+
'attemptDelay' => 120,
46+
];
47+
```
48+
49+
The array can define the following keys:
50+
51+
- `maxDepth` – The maximum depth that the plugin should go into objects/arrays when converting them to arrays for event payloads. (Default is `5`.)
52+
- `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`.)
54+
3655
## Managing Webhooks
3756

3857
To manage your webhooks, go to Settings → Webhooks in your project’s Control Panel.
@@ -73,6 +92,32 @@ The attributes listed here (separated by newlines) will be passed to the `$extra
7392

7493
For “Extra Event Attributes”, each attribute should be prefixed with the name of the property and a dot (e.g. `element.author` will include the `author` attribute of an `$element` property).
7594

95+
#### Sending Custom Payloads
96+
97+
You can completely customize the webhook payload by ticking the “Send a custom payload” checkbox. That will reveal the “Payload Template” field, where you can enter the desired body contents.
98+
99+
That field supports Twig, so you can make this dynamic. An `event` variable will be available to it that references the event that was triggered.
100+
101+
```twig
102+
{% set entry = event.sender %}
103+
{{
104+
{
105+
time: now|atom,
106+
user: currentUser.username ?? null,
107+
name: event.name,
108+
entry: {
109+
class: className(entry),
110+
id: entry.id,
111+
title: entry.title,
112+
slug: entry.slug,
113+
isNew: event.isNew
114+
}
115+
}|json_encode(options=0)
116+
}}
117+
```
118+
119+
If the output is valid JSON, then webhook requests will be sent with an `application/json` content type.
120+
76121
### Toggling Webhooks
77122

78123
Webhooks can be enabled or disabled from both the Webhooks index page and within their Edit Webhook pages.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "craftcms/webhooks",
33
"description": "Post webhooks when events are triggered in Craft CMS.",
4-
"version": "1.1.2",
4+
"version": "2.0.0",
55
"type": "craft-plugin",
66
"keywords": [
77
"html",
@@ -25,7 +25,7 @@
2525
"rss": "https://github.com/craftcms/webhooks/commits/master.atom"
2626
},
2727
"require": {
28-
"craftcms/cms": "^3.0.0"
28+
"craftcms/cms": "^3.1.19"
2929
},
3030
"autoload": {
3131
"psr-4": {

0 commit comments

Comments
 (0)