@5minds/node-red-contrib-processcube-tools 1.0.5 → 1.1.0

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.
package/.env.template CHANGED
@@ -2,3 +2,8 @@ EMAIL_SEND_PORT=
2
2
  EMAIL_SEND_HOST=
3
3
  EMAIL_SEND_USER=
4
4
  EMAIL_SEND_PASSWORD=
5
+
6
+ EMAIL_RECEIVE_PORT=
7
+ EMAIL_RECEIVE_HOST=
8
+ EMAIL_RECEIVE_USER=
9
+ EMAIL_RECEIVE_PASSWORD=
@@ -12,15 +12,28 @@
12
12
  tlsType: { value: 'bool' },
13
13
  user: { value: '', required: true, validate: RED.validators.typedInput('userType') },
14
14
  userType: { value: 'str' },
15
- password: { value: '', required: true, type: 'password' },
15
+ password: { value: '', required: true },
16
16
  passwordType: { value: 'env', required: true },
17
17
  folder: { value: '', required: true, validate: RED.validators.typedInput('folderType') },
18
18
  folderType: { value: 'json' },
19
19
  markseen: { value: true, validate: RED.validators.typedInput('markseenType') },
20
20
  markseenType: { value: 'bool' },
21
+ sendstatus: { value: true },
21
22
  },
22
23
  inputs: 1,
23
- outputs: 1,
24
+ // outputs: function () {
25
+ // const sendstatus = this.sendstatus === true || this.sendstatus === 'true';
26
+ // return sendstatus ? 2 : 1;
27
+ // },
28
+ outputs: 2,
29
+ outputLabels: function (index) {
30
+ if (index === 0) {
31
+ return 'Email Message';
32
+ }
33
+ if (index === 1) {
34
+ return 'Status';
35
+ }
36
+ },
24
37
  icon: 'font-awesome/fa-inbox',
25
38
  label: function () {
26
39
  return this.name || 'E-Mail Receiver';
@@ -118,6 +131,15 @@
118
131
  <input type="text" id="node-input-markseen" />
119
132
  <input type="hidden" id="node-input-markseenType" />
120
133
  </div>
134
+ <div class="form-row" style="margin-bottom: 3px;">
135
+ <input
136
+ type="checkbox"
137
+ checked
138
+ id="node-input-sendstatus"
139
+ style="display: inline-block; width: auto; vertical-align: top; margin-left: 5px;"
140
+ />
141
+ <label style="width:auto" for="node-input-sendstatus">Send status</label>
142
+ </div>
121
143
  </script>
122
144
 
123
145
  <script type="text/html" data-help-name="email-receiver">
@@ -24,6 +24,7 @@ module.exports = function (RED) {
24
24
  const imap_tls = RED.util.evaluateNodeProperty(config.tls, config.tlsType, node, msg);
25
25
  const imap_user = RED.util.evaluateNodeProperty(config.user, config.userType, node, msg);
26
26
  const imap_password = RED.util.evaluateNodeProperty(config.password, config.passwordType, node, msg);
27
+ const sendstatus = config.sendstatus === true || config.sendstatus === 'true';
27
28
 
28
29
  // Check if the folder is actually an array
29
30
  const imap_folder = RED.util.evaluateNodeProperty(config.folder, config.folderType, node, msg);
@@ -127,18 +128,51 @@ module.exports = function (RED) {
127
128
  if (error) {
128
129
  node.error('IMAP session terminated: ' + error.message);
129
130
  node.status({ fill: 'red', shape: 'ring', text: 'connection error' });
131
+ if (sendstatus) {
132
+ node.send([null, {
133
+ payload: {
134
+ status: 'error',
135
+ message: error.message,
136
+ errors: state.errors,
137
+ }
138
+ }]);
139
+ }
130
140
  } else if (state.failures > 0) {
131
141
  node.status({
132
142
  fill: 'red',
133
143
  shape: 'dot',
134
144
  text: `Done, ${state.totalMails} mails from ${state.successes}/${state.totalFolders} folders. ${state.failures} failed.`,
135
145
  });
146
+ if (sendstatus) {
147
+ node.send([null, {
148
+ payload: {
149
+ status: 'warning',
150
+ total: state.totalMails,
151
+ successes: state.successes,
152
+ failures: state.failures,
153
+ totalFolders: state.totalFolders,
154
+ errors: state.errors,
155
+ }
156
+ }]);
157
+ }
158
+
136
159
  } else {
137
160
  node.status({
138
161
  fill: 'green',
139
162
  shape: 'dot',
140
163
  text: `Done, fetched ${state.totalMails} mails from ${folders.join(', ')}.`,
141
164
  });
165
+
166
+ if (sendstatus) {
167
+ node.send([null, {
168
+ payload: {
169
+ status: 'success',
170
+ total: state.totalMails,
171
+ folders: folders.join(', '),
172
+ }
173
+ }]);
174
+ }
175
+
142
176
  }
143
177
  if (imap && imap.state !== 'disconnected') {
144
178
  imap.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube-tools",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED tools nodes for ProcessCube",
6
6
  "scripts": {