Skip to content

Commit d9ce9c7

Browse files
committed
Added new function to parse the tone options
1 parent dc91e62 commit d9ce9c7

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

  • services/tone_analyzer

services/tone_analyzer/v3.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,26 @@ module.exports = function (RED) {
102102
}
103103
};
104104

105+
// Function to parse and determine tone setting
106+
// 'all' is the setting which needs be be blanked
107+
// if not the service will throw an error
108+
var parseToneOption = function (msg, config) {
109+
var tones = msg.tones || config.tones;
110+
111+
return (tones === 'all' ? '' : tones);
112+
}
113+
105114
// function to parse through the options in preparation
106115
// for the sevice call.
107116
var parseOptions = function (msg, config) {
108-
var tones = msg.tones || config.tones;
109-
// var sentences = msg.sentences || config.sentences;
110-
// var contentType = msg.contentType || config.contentType;
111117

112118
var options = {
113119
'text': msg.payload,
114120
'sentences': msg.sentences || config.sentences,
115-
'isHTML': msg.contentType || config.contentType,
116-
'tones' : (tones === 'all' ? '' : tones)
121+
'isHTML': msg.contentType || config.contentType
117122
};
118123

119-
//if (tones !== 'all') {
120-
// options.tones = tones;
121-
//}
124+
options.tones = parseToneOption(msg, config);
122125

123126
return options;
124127
}

0 commit comments

Comments
 (0)