From b3b8d3c0860b6060a939a2f9405b2e8b594368ee Mon Sep 17 00:00:00 2001 From: Omar Sy Date: Wed, 22 Aug 2018 14:24:21 +0200 Subject: make the attributes that the webhook sends configurable --- server/notifications/outgoing.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/notifications/outgoing.js b/server/notifications/outgoing.js index 779d41a0..7e3ee60c 100644 --- a/server/notifications/outgoing.js +++ b/server/notifications/outgoing.js @@ -8,6 +8,8 @@ const postCatchError = Meteor.wrapAsync((url, options, resolve) => { }); }); +let webhooksAtbts = ( (process.env.WEBHOOKS_ATTRIBUTES && process.env.WEBHOOKS_ATTRIBUTES.split(',') ) || ['cardId', 'listId', 'oldListId', 'boardId', 'comment', 'user', 'card', 'commentId']); + Meteor.methods({ outgoingWebhooks(integrations, description, params) { check(integrations, Array); @@ -19,7 +21,7 @@ Meteor.methods({ if (quoteParams[key]) quoteParams[key] = `"${params[key]}"`; }); - const userId = (params.userId)?params.userId:integrations[0].userId; + const userId = (params.userId) ? params.userId : integrations[0].userId; const user = Users.findOne(userId); const text = `${params.user} ${TAPi18n.__(description, quoteParams, user.getLanguage())}\n${params.url}`; @@ -29,10 +31,7 @@ Meteor.methods({ text: `${text}`, }; - [ 'cardId', 'listId', 'oldListId', - 'boardId', 'comment', 'user', - 'card', 'commentId', - ].forEach((key) => { + webhooksAtbts.forEach((key) => { if (params[key]) value[key] = params[key]; }); value.description = description; -- cgit v1.2.3-1-g7c22 From fcbbb93bb663eec04e53230e447b2846f28d86e6 Mon Sep 17 00:00:00 2001 From: Omar Sy Date: Wed, 22 Aug 2018 15:07:46 +0200 Subject: change let to const --- server/notifications/outgoing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notifications/outgoing.js b/server/notifications/outgoing.js index 7e3ee60c..b35b3b2e 100644 --- a/server/notifications/outgoing.js +++ b/server/notifications/outgoing.js @@ -8,7 +8,7 @@ const postCatchError = Meteor.wrapAsync((url, options, resolve) => { }); }); -let webhooksAtbts = ( (process.env.WEBHOOKS_ATTRIBUTES && process.env.WEBHOOKS_ATTRIBUTES.split(',') ) || ['cardId', 'listId', 'oldListId', 'boardId', 'comment', 'user', 'card', 'commentId']); +const webhooksAtbts = ( (process.env.WEBHOOKS_ATTRIBUTES && process.env.WEBHOOKS_ATTRIBUTES.split(',') ) || ['cardId', 'listId', 'oldListId', 'boardId', 'comment', 'user', 'card', 'commentId']); Meteor.methods({ outgoingWebhooks(integrations, description, params) { -- cgit v1.2.3-1-g7c22 From d165733242eee22a1a2bb4e2bf451fa96857ef18 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Wed, 22 Aug 2018 22:19:06 +0300 Subject: - Add webhooks-attributes to Snap and Docker. Thanks to xet7 ! --- Dockerfile | 4 +++- docker-compose.yml | 3 +++ snap-src/bin/config | 6 +++++- snap-src/bin/wekan-help | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 94528ec9..e3371d55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ ARG MATOMO_DO_NOT_TRACK ARG MATOMO_WITH_USERNAME ARG BROWSER_POLICY_ENABLED ARG TRUSTED_URL +ARG WEBHOOKS_ATTRIBUTES # Set the environment variables (defaults where required) # DOES NOT WORK: paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303 @@ -36,7 +37,8 @@ ENV BUILD_DEPS="apt-utils gnupg gosu wget curl bzip2 build-essential python git MATOMO_DO_NOT_TRACK=true \ MATOMO_WITH_USERNAME=false \ BROWSER_POLICY_ENABLED=true \ - TRUSTED_URL="" + TRUSTED_URL="" \ + WEBHOOKS_ATTRIBUTES="" # Copy the app to the image COPY ${SRC_PATH} /home/wekan/app diff --git a/docker-compose.yml b/docker-compose.yml index 54866996..bf4d02cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,6 +60,9 @@ services: - BROWSER_POLICY_ENABLED=true # When browser policy is enabled, HTML code at this Trusted URL can have iframe that embeds Wekan inside. - TRUSTED_URL='' + # What to send to Outgoing Webhook, or leave out. Example, that includes all that are default: cardId,listId,oldListId,boardId,comment,user,card,commentId . + # example: WEBHOOKS_ATTRIBUTES=cardId,listId,oldListId,boardId,comment,user,card,commentId + - WEBHOOKS_ATTRIBUTES='' depends_on: - wekandb diff --git a/snap-src/bin/config b/snap-src/bin/config index 5a745184..85b71fa7 100755 --- a/snap-src/bin/config +++ b/snap-src/bin/config @@ -3,7 +3,7 @@ # All supported keys are defined here together with descriptions and default values # list of supported keys -keys="MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM ROOT_URL PORT DISABLE_MONGODB CADDY_ENABLED CADDY_BIND_PORT WITH_API MATOMO_ADDRESS MATOMO_SITE_ID MATOMO_DO_NOT_TRACK MATOMO_WITH_USERNAME BROWSER_POLICY_ENABLED TRUSTED_URL" +keys="MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM ROOT_URL PORT DISABLE_MONGODB CADDY_ENABLED CADDY_BIND_PORT WITH_API MATOMO_ADDRESS MATOMO_SITE_ID MATOMO_DO_NOT_TRACK MATOMO_WITH_USERNAME BROWSER_POLICY_ENABLED TRUSTED_URL WEBHOOKS_ATTRIBUTES" # default values DESCRIPTION_MONGODB_BIND_UNIX_SOCKET="mongodb binding unix socket:\n"\ @@ -77,3 +77,7 @@ KEY_BROWSER_POLICY_ENABLED="browser-policy-enabled" DESCRIPTION_TRUSTED_URL="When browser policy is enabled, HTML code at this Trusted URL can have iframe that embeds Wekan inside." DEFAULT_TRUSTED_URL="" KEY_TRUSTED_URL="trusted-url" + +DESCRIPTION_WEBHOOKS_ATTRIBUTES="What to send to Outgoing Webhook, or leave out. Example, that includes all that are default: cardId,listId,oldListId,boardId,comment,user,card,commentId ." +DEFAULT_WEBHOOKS_ATTRIBUTES="" +KEY_WEBHOOKS_ATTRIBUTES="webhooks-attributes" diff --git a/snap-src/bin/wekan-help b/snap-src/bin/wekan-help index 2cd0f037..76a27183 100755 --- a/snap-src/bin/wekan-help +++ b/snap-src/bin/wekan-help @@ -47,6 +47,12 @@ echo -e "\t$ snap set $SNAP_NAME TRUSTED_URL='https://example.com'" echo -e "\t-Disable the Trusted URL of Wekan:" echo -e "\t$ snap set $SNAP_NAME TRUSTED_URL=''" echo -e "\n" +echo -e "What to send to Outgoing Webhook, or leave out. Example, that includes all that are default: cardId,listId,oldListId,boardId,comment,user,card,commentId ." +echo -e "To enable the Webhooks Attributes of Wekan:" +echo -e "\t$ snap set $SNAP_NAME WEBHOOKS_ATTRIBUTES='cardId,listId,oldListId,boardId,comment,user,card,commentId'" +echo -e "\t-Disable the Webhooks Attributest of Wekan to send all default ones:" +echo -e "\t$ snap set $SNAP_NAME WEBHOOKS_ATTRIBUTES=''" +echo -e "\n" # parse config file for supported settings keys echo -e "wekan supports settings keys" echo -e "values can be changed by calling\n$ snap set $SNAP_NAME =''" -- cgit v1.2.3-1-g7c22