wingbot 3.31.7 → 3.31.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Tester.js +23 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.31.7",
3
+ "version": "3.31.8",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Tester.js CHANGED
@@ -69,9 +69,14 @@ class Tester {
69
69
  info: e => console.info(e) // eslint-disable-line
70
70
  };
71
71
 
72
+ this._cachedGiMap = null;
73
+
72
74
  this._listener = (senderIdentifier, action, text, req, prevAction, doNotTrack) => {
73
75
  const reqAction = req.action();
74
- if (reqAction && !this._actionMatches(action, reqAction)) {
76
+ if (reqAction
77
+ && !this._actionMatches(action, reqAction)
78
+ && this._actionHasGlobalIntent(reqAction)) {
79
+
75
80
  this._actionsCollector.push({
76
81
  action: reqAction, text, prevAction, doNotTrack, isReqAction: true
77
82
  });
@@ -134,10 +139,27 @@ class Tester {
134
139
  this.features = null;
135
140
  }
136
141
 
142
+ _actionHasGlobalIntent (action) {
143
+ if (!this.processor.reducer
144
+ || !('globalIntents' in this.processor.reducer)) {
145
+ return false;
146
+ }
147
+ if (this._cachedGiMap === null) {
148
+ this._cachedGiMap = new Set();
149
+
150
+ for (const value of this.processor.reducer.globalIntents.values()) {
151
+ this._cachedGiMap.add(value.action);
152
+ }
153
+ }
154
+
155
+ return this._cachedGiMap.has(action.replace(/^\/?/, '/'));
156
+ }
157
+
137
158
  dealloc () {
138
159
  this.processor.reducer
139
160
  .removeListener('_action', this._listener);
140
161
  this.processor.reducer = null;
162
+ this._cachedGiMap = null;
141
163
  }
142
164
 
143
165
  /**