From 2e9e7c297b8488d242b5e7535546ae9efad8a45a Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 7 Mar 2018 11:30:26 -0700 Subject: [PATCH 1/2] Fixed regression with workspaces --- Dockerfile.onbuild | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.onbuild b/Dockerfile.onbuild index 5739d6f95..3e837aad6 100644 --- a/Dockerfile.onbuild +++ b/Dockerfile.onbuild @@ -18,5 +18,6 @@ ONBUILD COPY . /usr/src/app # clear out the development dependencies again. After this we of course need to # clear out the yarn cache, this saves quite a lot of size. ONBUILD RUN cli plugins reconcile && \ + yarn && \ yarn build && \ yarn cache clean \ No newline at end of file From 48b5afafabb39277091bd7946d94841df9f133c5 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 7 Mar 2018 14:22:24 -0700 Subject: [PATCH 2/2] Resolves edge case with old digest frequency --- .../talk-plugin-notifications/server/hooks.js | 37 +++++++++++++++++++ .../talk-plugin-notifications/server/index.js | 21 ++++++----- 2 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 plugins/talk-plugin-notifications/server/hooks.js diff --git a/plugins/talk-plugin-notifications/server/hooks.js b/plugins/talk-plugin-notifications/server/hooks.js new file mode 100644 index 000000000..2a7eab608 --- /dev/null +++ b/plugins/talk-plugin-notifications/server/hooks.js @@ -0,0 +1,37 @@ +const { isValidJSValue } = require('graphql'); + +module.exports = { + NotificationSettings: { + digestFrequency: { + // This hook will swap out the digest frequency with `NONE` in the event + // that an org had a digest plugin enabled and later switched it off. This + // will force users that have previously had a digested option enabled to + // get notifications immediately until they update their frequency + // options. + post: async (settings, args, ctx, { schema }, frequency) => { + try { + // Validate that the type is correct. + const errors = isValidJSValue( + frequency, + schema.getType('DIGEST_FREQUENCY') + ); + if (errors && errors.length > 0) { + ctx.log.info( + { frequency }, + 'invalid frequency, swapping with `NONE`, plugin likely disabled' + ); + // Fallback to 'NONE' if the digest value has an error. + frequency = 'NONE'; + } + } catch (err) { + ctx.log.error({ err }, 'could not check if the type was valid'); + + // Fallback to 'NONE' if we couldn't validate the value. + frequency = 'NONE'; + } + + return frequency; + }, + }, + }, +}; diff --git a/plugins/talk-plugin-notifications/server/index.js b/plugins/talk-plugin-notifications/server/index.js index 0c7e993b9..816b9fbe3 100644 --- a/plugins/talk-plugin-notifications/server/index.js +++ b/plugins/talk-plugin-notifications/server/index.js @@ -1,16 +1,19 @@ const path = require('path'); -const connect = require('./connect'); -const typeDefs = require('./typeDefs'); -const resolvers = require('./resolvers'); -const router = require('./router'); -const mutators = require('./mutators'); const translations = path.join(__dirname, 'translations.yml'); +const connect = require('./connect'); +const hooks = require('./hooks'); +const mutators = require('./mutators'); +const resolvers = require('./resolvers'); +const router = require('./router'); +const typeDefs = require('./typeDefs'); + module.exports = { + connect, + hooks, + mutators, + resolvers, + router, translations, typeDefs, - resolvers, - mutators, - connect, - router, };