diff --git a/lib/package-lock.json b/lib/package-lock.json index bcc9f384..4a77cd67 100644 --- a/lib/package-lock.json +++ b/lib/package-lock.json @@ -1,12 +1,12 @@ { "name": "@alkemio/notifications-lib", - "version": "0.9.0", + "version": "0.9.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@alkemio/notifications-lib", - "version": "0.9.0", + "version": "0.9.6", "license": "EUPL-1.2", "dependencies": { "@alkemio/client-lib": "^0.32.0" @@ -215,9 +215,9 @@ } }, "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "bin": { "semver": "bin/semver.js" } @@ -2839,12 +2839,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -4258,9 +4258,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" @@ -5252,9 +5252,9 @@ } }, "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "peer": true, "bin": { @@ -6069,9 +6069,9 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "bin": { "json5": "lib/cli.js" }, @@ -6325,17 +6325,6 @@ "tslib": "^2.0.3" } }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -6353,9 +6342,9 @@ } }, "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "peer": true, "bin": { @@ -7341,12 +7330,9 @@ } }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dependencies": { - "lru-cache": "^6.0.0" - }, + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "bin": { "semver": "bin/semver.js" }, @@ -7900,9 +7886,9 @@ } }, "node_modules/tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", + "integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==", "dev": true, "peer": true, "dependencies": { @@ -8056,9 +8042,9 @@ } }, "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "dependencies": { "minimist": "^1.2.0" @@ -8472,9 +8458,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -8516,9 +8502,9 @@ } }, "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "peer": true, "engines": { @@ -8561,11 +8547,6 @@ "node": ">=10" } }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/yaml": { "version": "1.10.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", @@ -8765,9 +8746,9 @@ } }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==" } } }, @@ -10792,12 +10773,12 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" } }, "browser-process-hrtime": { @@ -11896,9 +11877,9 @@ } }, "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "requires": { "to-regex-range": "^5.0.1" @@ -12586,9 +12567,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "peer": true } @@ -13234,9 +13215,9 @@ "dev": true }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==" + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==" }, "kleur": { "version": "3.0.3", @@ -13434,14 +13415,6 @@ "tslib": "^2.0.3" } }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "requires": { - "yallist": "^4.0.0" - } - }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -13453,9 +13426,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "peer": true } @@ -14176,12 +14149,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "requires": { - "lru-cache": "^6.0.0" - } + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==" }, "semver-compare": { "version": "1.0.0", @@ -14626,9 +14596,9 @@ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" }, "tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", + "integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==", "dev": true, "peer": true, "requires": { @@ -14717,9 +14687,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" @@ -15031,9 +15001,9 @@ } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true }, "wrap-ansi": { @@ -15066,9 +15036,9 @@ } }, "ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "peer": true, "requires": {} @@ -15094,11 +15064,6 @@ "dev": true, "peer": true }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "yaml": { "version": "1.10.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", diff --git a/lib/package.json b/lib/package.json index a90a7ab3..e86f6537 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "@alkemio/notifications-lib", - "version": "0.9.3", + "version": "0.9.6", "description": "Library for interacting with Alkemio notifications service", "author": "Alkemio Foundation", "private": false, diff --git a/lib/src/dto/index.ts b/lib/src/dto/index.ts index 05c6fc43..b1a3afb7 100644 --- a/lib/src/dto/index.ts +++ b/lib/src/dto/index.ts @@ -25,3 +25,4 @@ export * from './platform.forum.discussion.comment.event.payload'; export * from './platform.forum.discussion.created.event.payload'; export * from './comment.reply.event.payload'; export * from './community.invitation.virtual.contributor.created.event.payload'; +export * from './space.created.event.payload'; diff --git a/lib/src/dto/space.created.event.payload.ts b/lib/src/dto/space.created.event.payload.ts new file mode 100644 index 00000000..076489fc --- /dev/null +++ b/lib/src/dto/space.created.event.payload.ts @@ -0,0 +1,9 @@ +import { SpaceBaseEventPayload } from "./space.base.event.payload"; + +export interface SpaceCreatedEventPayload extends SpaceBaseEventPayload { + created: number; + sender: { + name: string; + url: string; + } +} diff --git a/lib/src/notification.event.type.ts b/lib/src/notification.event.type.ts index 8c4a4eb7..ba69d170 100644 --- a/lib/src/notification.event.type.ts +++ b/lib/src/notification.event.type.ts @@ -23,4 +23,5 @@ export enum NotificationEventType { PLATFORM_FORUM_DISCUSSION_CREATED = 'platformForumDiscussionCreated', COMMENT_REPLY = 'commentReply', COMMUNITY_INVITATION_CREATED_VC = 'communityInvitationCreatedVC', + SPACE_CREATED = 'spaceCreated', } diff --git a/service/notifications.yml b/service/notifications.yml index 3fa52a79..b4b941f1 100644 --- a/service/notifications.yml +++ b/service/notifications.yml @@ -290,3 +290,9 @@ recipients: - rule: type: ORGANIZATION_ADMIN resource_id: + space_created: + - name: licenseManager + rules: + - rule: + type: GLOBAL_LICENSE_MANAGER + resource_id: diff --git a/service/package-lock.json b/service/package-lock.json index efe89510..9251ac54 100644 --- a/service/package-lock.json +++ b/service/package-lock.json @@ -1,16 +1,16 @@ { "name": "alkemio-notifications", - "version": "0.18.1", + "version": "0.19.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "alkemio-notifications", - "version": "0.18.1", + "version": "0.19.0", "license": "EUPL-1.2", "dependencies": { "@alkemio/client-lib": "^0.32.0", - "@alkemio/notifications-lib": "^0.9.3", + "@alkemio/notifications-lib": "^0.9.6", "@nestjs/common": "^8.0.5", "@nestjs/config": "^1.0.1", "@nestjs/core": "^8.0.5", @@ -186,9 +186,9 @@ } }, "node_modules/@alkemio/notifications-lib": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.9.3.tgz", - "integrity": "sha512-yqCGNbfT0CYwY0a0H1HZIw6KYiGMfpxch2SMe6BdFUeKaN4AZSiGsG1EuIDCV5/BM4EzYgPMe2O8yUpsAWLz6Q==", + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.9.6.tgz", + "integrity": "sha512-xIJ4JOmvo8grfGSeSM7GVfvuXMuIGZoDdcF37hBj/hKguQxzt3fpUMvR7pnWUbC6g5dbXZzoefZblcxreVd3tw==", "dependencies": { "@alkemio/client-lib": "^0.32.0" }, @@ -14687,9 +14687,9 @@ } }, "@alkemio/notifications-lib": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.9.3.tgz", - "integrity": "sha512-yqCGNbfT0CYwY0a0H1HZIw6KYiGMfpxch2SMe6BdFUeKaN4AZSiGsG1EuIDCV5/BM4EzYgPMe2O8yUpsAWLz6Q==", + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@alkemio/notifications-lib/-/notifications-lib-0.9.6.tgz", + "integrity": "sha512-xIJ4JOmvo8grfGSeSM7GVfvuXMuIGZoDdcF37hBj/hKguQxzt3fpUMvR7pnWUbC6g5dbXZzoefZblcxreVd3tw==", "requires": { "@alkemio/client-lib": "^0.32.0" } diff --git a/service/package.json b/service/package.json index 49034dd3..3f4b63ef 100644 --- a/service/package.json +++ b/service/package.json @@ -1,6 +1,6 @@ { "name": "alkemio-notifications", - "version": "0.18.1", + "version": "0.19.0", "description": "Alkemio notifications service", "author": "Alkemio Foundation", "private": false, @@ -36,7 +36,7 @@ }, "dependencies": { "@alkemio/client-lib": "^0.32.0", - "@alkemio/notifications-lib": "^0.9.3", + "@alkemio/notifications-lib": "^0.9.6", "@nestjs/common": "^8.0.5", "@nestjs/config": "^1.0.1", "@nestjs/core": "^8.0.5", diff --git a/service/src/app.controller.ts b/service/src/app.controller.ts index 6baae44d..e56b9ffa 100644 --- a/service/src/app.controller.ts +++ b/service/src/app.controller.ts @@ -34,10 +34,11 @@ import { CommunityInvitationCreatedEventPayload, CommentReplyEventPayload, CommunityInvitationVirtualContributorCreatedEventPayload, + CommunityPlatformInvitationCreatedEventPayload, + SpaceCreatedEventPayload, } from '@alkemio/notifications-lib'; import { NotificationService } from './services/domain/notification/notification.service'; import { ALKEMIO_CLIENT_ADAPTER, LogContext } from './common/enums'; -import { CommunityPlatformInvitationCreatedEventPayload } from '@alkemio/notifications-lib'; @Controller() export class AppController { @@ -380,6 +381,20 @@ export class AppController { ); } + @EventPattern(NotificationEventType.SPACE_CREATED) + async sendSpaceCreatedNotifications( + @Payload() + eventPayload: SpaceCreatedEventPayload, + @Ctx() context: RmqContext + ) { + this.sendNotifications( + eventPayload, + context, + this.notificationService.sendSpaceCreatedNotification(eventPayload), + NotificationEventType.SPACE_CREATED + ); + } + private async sendNotifications( @Payload() eventPayload: BaseEventPayload, @Ctx() context: RmqContext, diff --git a/service/src/app.module.ts b/service/src/app.module.ts index d471de4c..f07e920b 100644 --- a/service/src/app.module.ts +++ b/service/src/app.module.ts @@ -42,6 +42,7 @@ import { AlkemioUrlGeneratorModule } from './services/application/alkemio-url-ge import { PlatformGlobalRoleChangeNotificationBuilder } from './services/domain/builders/platform-global-role-change/platform.global.role.change.notification.builder'; import { CommunityInvitationVirtualContributorCreatedNotificationBuilder } from './services/domain/builders/community-invitation-virtual-contributor-created/community.invitation.virtual.contributor.created.notification.builder'; import { HealthController } from './health.controller'; +import { SpaceCreatedNotificationBuilder } from './services/domain/builders/space-created/space.created.notification.builder'; @Module({ imports: [ @@ -89,6 +90,7 @@ import { HealthController } from './health.controller'; CommentReplyNotificationBuilder, NotificationService, CommunityInvitationVirtualContributorCreatedNotificationBuilder, + SpaceCreatedNotificationBuilder, ], controllers: [AppController, HealthController], }) diff --git a/service/src/common/email-template-payload/index.ts b/service/src/common/email-template-payload/index.ts index 5f19f12e..8c9cfc60 100644 --- a/service/src/common/email-template-payload/index.ts +++ b/service/src/common/email-template-payload/index.ts @@ -22,3 +22,4 @@ export * from './platform.forum.discussion.comment.email.payload'; export * from './platform.forum.discussion.created.email.payload'; export * from './comment.reply.email.payload'; export * from './community.invitation.virtual.contributor.created.email.payload'; +export * from './space.created.email.payload'; diff --git a/service/src/common/email-template-payload/space.created.email.payload.ts b/service/src/common/email-template-payload/space.created.email.payload.ts new file mode 100644 index 00000000..9bdcc0e5 --- /dev/null +++ b/service/src/common/email-template-payload/space.created.email.payload.ts @@ -0,0 +1,14 @@ +import { BaseJourneyEmailPayload } from './base.journey.email.payload'; + +export interface SpaceCreatedEmailPayload extends BaseJourneyEmailPayload { + space: { + displayName: string; + url: string; + type: string; + }; + dateCreated: string; + sender: { + name: string; + url: string; + }; +} diff --git a/service/src/common/enums/email.template.ts b/service/src/common/enums/email.template.ts index edc829ed..91a64d4d 100644 --- a/service/src/common/enums/email.template.ts +++ b/service/src/common/enums/email.template.ts @@ -37,4 +37,5 @@ export enum EmailTemplate { PLATFORM_FORUM_DISCUSSION_COMMENT = 'platform.forum.discussion.comment', COMMENT_REPLY = 'comment.reply', COMMUNITY_INVITATION_CREATED_VC_HOST = 'community.invitation.created.vc.host', + SPACE_CREATED_ADMIN = 'space.created.license.manager', } diff --git a/service/src/core/contracts/notification.recipient.template.provider.interface.ts b/service/src/core/contracts/notification.recipient.template.provider.interface.ts index 98a31f50..7f806e6a 100644 --- a/service/src/core/contracts/notification.recipient.template.provider.interface.ts +++ b/service/src/core/contracts/notification.recipient.template.provider.interface.ts @@ -38,6 +38,7 @@ export type TemplateConfig = { platform_forum_discussion_comment?: TemplateRuleSet[]; comment_reply?: TemplateRuleSet[]; community_invitation_created_vc?: TemplateRuleSet[]; + space_created?: TemplateRuleSet[]; }; export interface INotificationRecipientTemplateProvider { diff --git a/service/src/services/application/notification-builder/notification.builder.spec.ts b/service/src/services/application/notification-builder/notification.builder.spec.ts index 99615afe..9b07e22c 100644 --- a/service/src/services/application/notification-builder/notification.builder.spec.ts +++ b/service/src/services/application/notification-builder/notification.builder.spec.ts @@ -62,7 +62,8 @@ describe('NotificationBuilder', () => { await notificationBuilder.build(getBaseOptions()); expect(loggerSpy).toBeCalledWith( - expect.stringContaining('No rule set(s) found for roles') + expect.stringContaining('No rule set(s) found for roles'), + expect.stringMatching('notifications') ); }); }); diff --git a/service/src/services/domain/builders/space-created/space.created.notification.builder.ts b/service/src/services/domain/builders/space-created/space.created.notification.builder.ts new file mode 100644 index 00000000..a675bf0e --- /dev/null +++ b/service/src/services/domain/builders/space-created/space.created.notification.builder.ts @@ -0,0 +1,77 @@ +import { Injectable } from '@nestjs/common'; +import { INotificationBuilder } from '@core/contracts'; +import { NotificationTemplateType } from '@src/types'; +import { SpaceCreatedEventPayload } from '@alkemio/notifications-lib'; +import { EmailTemplate } from '@src/common/enums/email.template'; +import { + AlkemioUrlGenerator, + NotificationBuilder, + RoleConfig, +} from '../../../application'; +import { PlatformUser, User } from '@src/core/models'; +import { SpaceCreatedEmailPayload } from '@src/common/email-template-payload'; + +@Injectable() +export class SpaceCreatedNotificationBuilder implements INotificationBuilder { + constructor( + private readonly alkemioUrlGenerator: AlkemioUrlGenerator, + private readonly notificationBuilder: NotificationBuilder< + SpaceCreatedEventPayload, + SpaceCreatedEmailPayload + > + ) {} + + build( + payload: SpaceCreatedEventPayload + ): Promise { + const roleConfig: RoleConfig[] = [ + { + role: 'licenseManager', + emailTemplate: EmailTemplate.SPACE_CREATED_ADMIN, + }, + ]; + + const templateVariables = { + spaceID: payload.space.id, + senderID: payload.triggeredBy, + }; + + return this.notificationBuilder.build({ + payload, + eventUserId: undefined, + roleConfig, + templateType: 'space_created', + templateVariables, + templatePayloadBuilderFn: this.createTemplatePayload.bind(this), + }); + } + + createTemplatePayload( + eventPayload: SpaceCreatedEventPayload, + recipient: User | PlatformUser + ): SpaceCreatedEmailPayload { + const notificationPreferenceURL = + this.alkemioUrlGenerator.createUserNotificationPreferencesURL(recipient); + + return { + emailFrom: 'info@alkem.io', + recipient: { + firstName: recipient.firstName, + email: recipient.email, + notificationPreferences: notificationPreferenceURL, + }, + space: { + displayName: eventPayload.space.profile.displayName, + type: eventPayload.space.type, + url: eventPayload.space.profile.url, + }, + sender: eventPayload.sender, + dateCreated: new Date(eventPayload.created).toLocaleString('en-GB', { + timeZone: 'UTC', + }), + platform: { + url: eventPayload.platform.url, + }, + }; + } +} diff --git a/service/src/services/domain/notification/notification.service.spec.ts b/service/src/services/domain/notification/notification.service.spec.ts index a8588873..9ed0b2db 100644 --- a/service/src/services/domain/notification/notification.service.spec.ts +++ b/service/src/services/domain/notification/notification.service.spec.ts @@ -47,6 +47,7 @@ import { CollaborationWhiteboardCreatedNotificationBuilder } from '../builders/c import { CollaborationDiscussionCommentNotificationBuilder } from '../builders/collaboration-discussion-comment/collaboration.discussion.comment.notification.builder'; import { PlatformGlobalRoleChangeNotificationBuilder } from '../builders/platform-global-role-change/platform.global.role.change.notification.builder'; import { CommunityInvitationVirtualContributorCreatedNotificationBuilder } from '../builders/community-invitation-virtual-contributor-created/community.invitation.virtual.contributor.created.notification.builder'; +import { SpaceCreatedNotificationBuilder } from '../builders/space-created/space.created.notification.builder'; const testData = { ...challengeAdminsData, @@ -97,6 +98,7 @@ describe('NotificationService', () => { MockConfigServiceProvider, MockAlkemioClientAdapterProvider, AlkemioUrlGenerator, + SpaceCreatedNotificationBuilder, ], }).compile(); diff --git a/service/src/services/domain/notification/notification.service.ts b/service/src/services/domain/notification/notification.service.ts index 73a671db..c74615e1 100644 --- a/service/src/services/domain/notification/notification.service.ts +++ b/service/src/services/domain/notification/notification.service.ts @@ -29,6 +29,7 @@ import { CommentReplyEventPayload, PlatformGlobalRoleChangeEventPayload, CommunityInvitationVirtualContributorCreatedEventPayload, + SpaceCreatedEventPayload, } from '@alkemio/notifications-lib'; import { AlkemioClientAdapter } from '@src/services/application/alkemio-client-adapter'; import { NotificationTemplateType } from '@src/types/notification.template.type'; @@ -59,6 +60,7 @@ import { CommentReplyNotificationBuilder } from '../builders/comment-reply/comme import { CommunityPlatformInvitationCreatedEventPayload } from '@alkemio/notifications-lib'; import { PlatformGlobalRoleChangeNotificationBuilder } from '../builders/platform-global-role-change/platform.global.role.change.notification.builder'; import { CommunityInvitationVirtualContributorCreatedNotificationBuilder } from '../builders/community-invitation-virtual-contributor-created/community.invitation.virtual.contributor.created.notification.builder'; +import { SpaceCreatedNotificationBuilder } from '../builders/space-created/space.created.notification.builder'; @Injectable() export class NotificationService { @@ -90,7 +92,8 @@ export class NotificationService { private collaborationCalloutPublishedNotificationBuilder: CollaborationCalloutPublishedNotificationBuilder, private collaborationDiscussionCommentNotificationBuilder: CollaborationDiscussionCommentNotificationBuilder, private commentReplyNotificationBuilder: CommentReplyNotificationBuilder, - private communityInvitationvirtualContributorCreatedNotificationBuilder: CommunityInvitationVirtualContributorCreatedNotificationBuilder + private communityInvitationvirtualContributorCreatedNotificationBuilder: CommunityInvitationVirtualContributorCreatedNotificationBuilder, + private spaceCreatedNotificationBuilder: SpaceCreatedNotificationBuilder ) {} async sendNotifications( @@ -317,6 +320,15 @@ export class NotificationService { ); } + async sendSpaceCreatedNotification( + payload: SpaceCreatedEventPayload + ): Promise[]> { + return this.sendNotifications( + payload, + this.spaceCreatedNotificationBuilder + ); + } + private async sendNotification( notification: NotificationTemplateType ): Promise { diff --git a/service/src/templates/space.created.license.manager.js b/service/src/templates/space.created.license.manager.js new file mode 100644 index 00000000..9c0c12e1 --- /dev/null +++ b/service/src/templates/space.created.license.manager.js @@ -0,0 +1,24 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +var templates = require('./alkemio.template.blocks'); +/* eslint-disable quotes */ +module.exports = () => ({ + name: 'space-created-license-manager', + title: '', + version: 1, + channels: { + email: { + from: '{{emailFrom}}', + to: '{{recipient.email}}', + subject: 'New space created - {{space.displayName}}', + html: `{% extends "src/templates/_layouts/email-transactional.html" %} + {% block content %}Hi {{recipient.firstName}},

+ + {{sender.name}} created a new space "{{space.displayName}}" on {{dateCreated}} UTC. +

+ HAVE A LOOK!

+ {% endblock %} + ${templates.footerBlock}`, + }, + }, +}); +