Skip to content

Commit 7e7a3f8

Browse files
authored
Merge pull request #783 from bobpskier/update-transcript-redaction
Revise handling of connect transcript redaction.
2 parents fb64e9e + 5477c69 commit 7e7a3f8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lex-web-ui/src/store/getters.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ export default {
6464
// reconnects with an agent.
6565
const messageTextArray = [];
6666
var text = "";
67-
let shouldRedactResponse = false; // indicates if the current message should be redacted
68-
const regex = new RegExp(`${state.config.connect.transcriptRedactRegex}`, "g");
67+
let redactionEnabled = false;
68+
if (state.config.connect.transcriptRedactRegex && state.config.connect.transcriptRedactRegex.length > 0) {
69+
redactionEnabled = true;
70+
}
71+
let shouldRedactNextMessage = false; // indicates if the next message to append should be redacted
72+
const regex = redactionEnabled ? new RegExp(`${state.config.connect.transcriptRedactRegex}`, "g") : undefined;
6973
state.messages.forEach((message) => {
7074
var nextMessage = message.date.toLocaleTimeString() + ' ' + (message.type === 'bot' ? 'Bot' : 'Human') + ': ' + message.text + '\n';
71-
if (shouldRedactResponse) {
75+
if (redactionEnabled && shouldRedactNextMessage) {
7276
nextMessage = message.date.toLocaleTimeString() + ' ' + (message.type === 'bot' ? 'Bot' : 'Human') + ': ' + '###' + '\n';
7377
}
7478
if((text + nextMessage).length > 400) {
@@ -79,10 +83,15 @@ export default {
7983
messageTextArray.push(subMsg);
8084
});
8185
text = "";
82-
shouldRedactResponse= regex.test(nextMessage);
86+
if (redactionEnabled && regex) {
87+
shouldRedactNextMessage = regex.test(nextMessage);
88+
}
8389
nextMessage = "";
8490
} else {
85-
shouldRedactResponse= regex.test(nextMessage);
91+
if (redactionEnabled && regex) {
92+
// if we are redacting, check if the next message should be redacted
93+
shouldRedactNextMessage = regex.test(nextMessage);
94+
}
8695
}
8796
text = text + nextMessage;
8897
});

0 commit comments

Comments
 (0)