diff --git a/config/config.json b/config/config.json
index 60e197154c..1dbd05a79a 100644
--- a/config/config.json
+++ b/config/config.json
@@ -5,7 +5,7 @@
"SegmentDeveloperKey": "",
"GoogleDeveloperKey": "",
"EnableOAuthServiceProvider": false,
- "EnableIncomingWebhooks": false,
+ "EnableIncomingWebhooks": true,
"EnableTesting": false
},
"TeamSettings": {
@@ -86,4 +86,4 @@
"TokenEndpoint": "",
"UserApiEndpoint": ""
}
-}
\ No newline at end of file
+}
diff --git a/doc/integrations/webhook/incoming.md b/doc/integrations/webhook/incoming.md
index a48448cc51..e391cba920 100644
--- a/doc/integrations/webhook/incoming.md
+++ b/doc/integrations/webhook/incoming.md
@@ -20,6 +20,11 @@ You can send the message by including a JSON string as the `payload` parameter i
payload={"text": "Hello, this is some text."}
```
+In addition, if `Content-Type` is specified as `application/json` in the headers of the HTTP request then the body of the request can be direct JSON.
+```
+{"text": "Hello, this is some text."}
+```
+
It is also possible to post richly formatted messages using [Markdown](../../help/enduser/markdown.md).
```
payload={"text": "# A Header\nThe _text_ below **the** header."}
diff --git a/web/react/components/user_settings/manage_incoming_hooks.jsx b/web/react/components/user_settings/manage_incoming_hooks.jsx
index 1bbfbd162a..fa2e2e5e41 100644
--- a/web/react/components/user_settings/manage_incoming_hooks.jsx
+++ b/web/react/components/user_settings/manage_incoming_hooks.jsx
@@ -21,7 +21,7 @@ export default class ManageIncomingHooks extends React.Component {
this.getHooks();
}
addNewHook() {
- let hook = {}; //eslint-disable-line prefer-const
+ const hook = {};
hook.channel_id = this.state.channelId;
Client.addIncomingHook(
@@ -40,13 +40,13 @@ export default class ManageIncomingHooks extends React.Component {
);
}
removeHook(id) {
- let data = {}; //eslint-disable-line prefer-const
+ const data = {};
data.id = id;
Client.deleteIncomingHook(
data,
() => {
- let hooks = this.state.hooks; //eslint-disable-line prefer-const
+ const hooks = this.state.hooks;
let index = -1;
for (let i = 0; i < hooks.length; i++) {
if (hooks[i].id === id) {
@@ -69,7 +69,7 @@ export default class ManageIncomingHooks extends React.Component {
getHooks() {
Client.listIncomingHooks(
(data) => {
- let state = this.state; //eslint-disable-line prefer-const
+ const state = this.state;
if (data) {
state.hooks = data;
@@ -93,9 +93,11 @@ export default class ManageIncomingHooks extends React.Component {
}
const channels = ChannelStore.getAll();
- let options = []; //eslint-disable-line prefer-const
+ const options = [];
channels.forEach((channel) => {
- options.push();
+ if (channel.type !== Constants.DM_CHANNEL) {
+ options.push();
+ }
});
let disableButton = '';
@@ -103,7 +105,7 @@ export default class ManageIncomingHooks extends React.Component {
disableButton = ' disable';
}
- let hooks = []; //eslint-disable-line prefer-const
+ const hooks = [];
this.state.hooks.forEach((hook) => {
const c = ChannelStore.get(hook.channel_id);
hooks.push(
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index 75e80bc7ef..da59f8e5a7 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -111,6 +111,7 @@ module.exports = {
],
MONTHS: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
MAX_DMS: 20,
+ DM_CHANNEL: 'D',
MAX_POST_LEN: 4000,
EMOJI_SIZE: 16,
ONLINE_ICON_SVG: "",
diff --git a/web/web.go b/web/web.go
index da7eff13da..bf985a5a0a 100644
--- a/web/web.go
+++ b/web/web.go
@@ -850,7 +850,12 @@ func incomingWebhook(c *api.Context, w http.ResponseWriter, r *http.Request) {
r.ParseForm()
- props := model.MapFromJson(strings.NewReader(r.FormValue("payload")))
+ var props map[string]string
+ if r.Header.Get("Content-Type") == "application/json" {
+ props = model.MapFromJson(r.Body)
+ } else {
+ props = model.MapFromJson(strings.NewReader(r.FormValue("payload")))
+ }
text := props["text"]
if len(text) == 0 {