@plusscommunities/pluss-core-aws 2.0.20-beta.0 → 2.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,34 @@
1
- module.exports = () => {};
1
+ const getActionBySiteTrigger = require("../db/automatedactions/getActionBySiteTrigger");
2
+ const sendEmail = require("./sendEmail");
3
+
4
+ const isActionConditionMet = (action, args = {}) => {
5
+ if (!action) return false;
6
+ if (!action?.Condition) return true;
7
+ return args[action.Condition.type] === action.Condition.value;
8
+ };
9
+
10
+ module.exports = async (site, trigger, args = {}) => {
11
+ const actions = await getActionBySiteTrigger(site, trigger);
12
+ for await (const action of actions) {
13
+ if (!isActionConditionMet(action, args)) continue;
14
+
15
+ switch (action.ActionType) {
16
+ case "email":
17
+ let subject = action.ActionData.Subject;
18
+ let content = action.ActionData.Content;
19
+ let email = action.ActionData.Email;
20
+ Object.keys(args).forEach((key) => {
21
+ subject = subject.replace(`__${key}__`, args[key]);
22
+ content = content.replace(`__${key}__`, args[key]);
23
+ email = email.replace(`__${key}__`, args[key]);
24
+ });
25
+ // console.log("triggerAutomatedAction - email", {
26
+ // subject,
27
+ // content,
28
+ // email,
29
+ // });
30
+ await sendEmail(email, subject, content);
31
+ break;
32
+ }
33
+ }
34
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "2.0.20-beta.0",
3
+ "version": "2.0.20",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",