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.',
|
||||
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
|
||||
anonymousDisplayName: 'Anonymous',
|
||||
enableEncryption: 'no',
|
||||
}
|
||||
|
||||
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_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_ENCRYPTION = "yes"
|
||||
|
||||
|
||||
class ChatBox extends React.Component {
|
||||
@ -229,11 +230,15 @@ class ChatBox extends React.Component {
|
||||
client.setDisplayName(this.props.anonymousDisplayName)
|
||||
this.setMatrixListeners(client)
|
||||
|
||||
if(this.props.enableEncryption == "yes"){
|
||||
try {
|
||||
await client.initCrypto()
|
||||
} catch(err) {
|
||||
return this.initializeUnencryptedChat()
|
||||
}
|
||||
}else{
|
||||
return this.initializeUnencryptedChat()
|
||||
}
|
||||
|
||||
await client.startClient()
|
||||
await this.createRoom(client)
|
||||
@ -257,7 +262,9 @@ class ChatBox extends React.Component {
|
||||
isCryptoEnabled: false,
|
||||
})
|
||||
|
||||
if(this.props.enableEncryption == "yes"){
|
||||
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE })
|
||||
}
|
||||
|
||||
let opts = {
|
||||
baseUrl: this.props.matrixServerUrl,
|
||||
@ -277,7 +284,9 @@ class ChatBox extends React.Component {
|
||||
client.setDisplayName(this.props.anonymousDisplayName)
|
||||
await this.createRoom(client)
|
||||
await client.startClient()
|
||||
if(this.props.enableEncryption == "yes"){
|
||||
this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
|
||||
}
|
||||
} catch(err) {
|
||||
console.log("error", err)
|
||||
this.handleInitError(err)
|
||||
@ -715,6 +724,7 @@ ChatBox.propTypes = {
|
||||
chatUnavailableMessage: PropTypes.string,
|
||||
anonymousDisplayName: PropTypes.string,
|
||||
waitMessage: PropTypes.string,
|
||||
enableEncryption: PropTypes.string,
|
||||
}
|
||||
|
||||
ChatBox.defaultProps = {
|
||||
@ -729,6 +739,7 @@ ChatBox.defaultProps = {
|
||||
anonymousDisplayName: DEFAULT_ANONYMOUS_DISPLAY_NAME,
|
||||
chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE,
|
||||
waitMessage: DEFAULT_WAIT_MESSAGE,
|
||||
enableEncryption: DEFAULT_ENCRYPTION,
|
||||
}
|
||||
|
||||
export default ChatBox;
|
||||
|
@ -11,6 +11,7 @@ const config = {
|
||||
exitMessage: 'The chat is closed. You may close this window.',
|
||||
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
|
||||
anonymousDisplayName: 'Anonymous',
|
||||
enableEncryption: 'no',
|
||||
}
|
||||
|
||||
export default function bookmarklet() {
|
||||
|
Loading…
Reference in New Issue
Block a user