forked from Github/safesupport-chatbox
add a flag to disable encryption by default
This commit is contained in:
parent
569a8e76c2
commit
a91ca1a092
@ -23,6 +23,7 @@
|
|||||||
exitMessage: 'The chat is closed. You may close this window.',
|
exitMessage: 'The chat is closed. You may close this window.',
|
||||||
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
|
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
|
||||||
anonymousDisplayName: 'Anonymous',
|
anonymousDisplayName: 'Anonymous',
|
||||||
|
enableEncryption: 'no',
|
||||||
}
|
}
|
||||||
|
|
||||||
EmbeddableChatbox.mount(config);
|
EmbeddableChatbox.mount(config);
|
||||||
|
@ -38,6 +38,7 @@ const DEFAULT_EXIT_MESSAGE = "The chat is closed. You may close this window."
|
|||||||
const DEFAULT_ANONYMOUS_DISPLAY_NAME="Anonymous"
|
const DEFAULT_ANONYMOUS_DISPLAY_NAME="Anonymous"
|
||||||
const DEFAULT_CHAT_UNAVAILABLE_MESSAGE = "The chat service is not available right now. Please try again later."
|
const DEFAULT_CHAT_UNAVAILABLE_MESSAGE = "The chat service is not available right now. Please try again later."
|
||||||
const DEFAULT_WAIT_MESSAGE = "Please be patient, our online facilitators are currently responding to other support requests."
|
const DEFAULT_WAIT_MESSAGE = "Please be patient, our online facilitators are currently responding to other support requests."
|
||||||
|
const DEFAULT_ENCRYPTION = "yes"
|
||||||
|
|
||||||
|
|
||||||
class ChatBox extends React.Component {
|
class ChatBox extends React.Component {
|
||||||
@ -229,9 +230,13 @@ class ChatBox extends React.Component {
|
|||||||
client.setDisplayName(this.props.anonymousDisplayName)
|
client.setDisplayName(this.props.anonymousDisplayName)
|
||||||
this.setMatrixListeners(client)
|
this.setMatrixListeners(client)
|
||||||
|
|
||||||
try {
|
if(this.props.enableEncryption == "yes"){
|
||||||
await client.initCrypto()
|
try {
|
||||||
} catch(err) {
|
await client.initCrypto()
|
||||||
|
} catch(err) {
|
||||||
|
return this.initializeUnencryptedChat()
|
||||||
|
}
|
||||||
|
}else{
|
||||||
return this.initializeUnencryptedChat()
|
return this.initializeUnencryptedChat()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +262,9 @@ class ChatBox extends React.Component {
|
|||||||
isCryptoEnabled: false,
|
isCryptoEnabled: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE })
|
if(this.props.enableEncryption == "yes"){
|
||||||
|
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE })
|
||||||
|
}
|
||||||
|
|
||||||
let opts = {
|
let opts = {
|
||||||
baseUrl: this.props.matrixServerUrl,
|
baseUrl: this.props.matrixServerUrl,
|
||||||
@ -277,7 +284,9 @@ class ChatBox extends React.Component {
|
|||||||
client.setDisplayName(this.props.anonymousDisplayName)
|
client.setDisplayName(this.props.anonymousDisplayName)
|
||||||
await this.createRoom(client)
|
await this.createRoom(client)
|
||||||
await client.startClient()
|
await client.startClient()
|
||||||
this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
|
if(this.props.enableEncryption == "yes"){
|
||||||
|
this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
|
||||||
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log("error", err)
|
console.log("error", err)
|
||||||
this.handleInitError(err)
|
this.handleInitError(err)
|
||||||
@ -715,6 +724,7 @@ ChatBox.propTypes = {
|
|||||||
chatUnavailableMessage: PropTypes.string,
|
chatUnavailableMessage: PropTypes.string,
|
||||||
anonymousDisplayName: PropTypes.string,
|
anonymousDisplayName: PropTypes.string,
|
||||||
waitMessage: PropTypes.string,
|
waitMessage: PropTypes.string,
|
||||||
|
enableEncryption: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatBox.defaultProps = {
|
ChatBox.defaultProps = {
|
||||||
@ -729,6 +739,7 @@ ChatBox.defaultProps = {
|
|||||||
anonymousDisplayName: DEFAULT_ANONYMOUS_DISPLAY_NAME,
|
anonymousDisplayName: DEFAULT_ANONYMOUS_DISPLAY_NAME,
|
||||||
chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE,
|
chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE,
|
||||||
waitMessage: DEFAULT_WAIT_MESSAGE,
|
waitMessage: DEFAULT_WAIT_MESSAGE,
|
||||||
|
enableEncryption: DEFAULT_ENCRYPTION,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ChatBox;
|
export default ChatBox;
|
||||||
|
@ -11,6 +11,7 @@ const config = {
|
|||||||
exitMessage: 'The chat is closed. You may close this window.',
|
exitMessage: 'The chat is closed. You may close this window.',
|
||||||
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
|
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
|
||||||
anonymousDisplayName: 'Anonymous',
|
anonymousDisplayName: 'Anonymous',
|
||||||
|
enableEncryption: 'no',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function bookmarklet() {
|
export default function bookmarklet() {
|
||||||
|
Loading…
Reference in New Issue
Block a user