Compare commits

...

2 Commits

Author SHA1 Message Date
fadc9b642f fix and build 2022-04-21 08:56:42 -06:00
758af0c29b disable encryption flag 2022-04-21 08:30:24 -06:00
6 changed files with 24 additions and 10 deletions

View File

@ -23,6 +23,7 @@ Built on:
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: 'yes',
} }
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);
@ -46,6 +47,7 @@ Options:
| `size` (optional) | The size of the start button. Can be 'small' or 'large' | `large` | | `size` (optional) | The size of the start button. Can be 'small' or 'large' | `large` |
| `position` (optional) | The position of the start button. Can be 'top left', 'top right', 'bottom left', 'bottom right'. | `bottom right` | | `position` (optional) | The position of the start button. Can be 'top left', 'top right', 'bottom left', 'bottom right'. | `bottom right` |
| `waitInterval` (optional) | The interval (in ms) at which the bot sends the wait message | 120000 | | `waitInterval` (optional) | The interval (in ms) at which the bot sends the wait message | 120000 |
| `enableEncryption` (optional) | if set to "yes" then the chat will be encrypted by default | `yes` |
## Feature list ## Feature list
@ -86,7 +88,7 @@ You can try this out on the [live demo](https://nomadic-labs.github.io/safesuppo
Clone the project: Clone the project:
``` ```
git clone https://github.com/Safe-Support-Chat/ocrcc-chatbox.git git clone https://git.umycode.com/dave/ocrcc-chatbox.git
``` ```
Install the dependencies: Install the dependencies:
``` ```

4
dist/bookmarklet.js vendored

File diff suppressed because one or more lines are too long

2
dist/chatbox.js vendored

File diff suppressed because one or more lines are too long

2
dist/component.js vendored

File diff suppressed because one or more lines are too long

View File

@ -221,11 +221,16 @@ class ChatBox extends React.Component {
this.setState({ ready: false }) this.setState({ ready: false })
const client = await this.createClientWithAccount() const client = await this.createClientWithAccount()
if(this.props.enableEncryption == "yes"){
try { try {
await client.initCrypto() await client.initCrypto()
} catch(err) { } catch(err) {
return this.restartWithoutCrypto() return this.restartWithoutCrypto()
} }
}else{
return this.restartWithoutCrypto()
}
await client.startClient() await client.startClient()
@ -257,7 +262,9 @@ class ChatBox extends React.Component {
isCryptoEnabled: false, isCryptoEnabled: false,
}) })
if(this.props.enableEncryption == "yes"){
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE }) 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.displayName) client.setDisplayName(this.props.displayName)
this.setMatrixListeners(client) this.setMatrixListeners(client)
await this.createRoom(client) await this.createRoom(client)
if(this.props.enableEncryption == "yes"){
this.displayBotMessage({ body: UNENCRYPTION_NOTICE }) this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
}
} catch(err) { } catch(err) {
console.log("error", err) console.log("error", err)
this.handleInitError(err) this.handleInitError(err)
@ -767,6 +776,7 @@ ChatBox.propTypes = {
chatUnavailableMessage: PropTypes.string, chatUnavailableMessage: PropTypes.string,
displayName: PropTypes.string, displayName: PropTypes.string,
waitMessage: PropTypes.string, waitMessage: PropTypes.string,
enableEncryption: PropTypes.string,
chatOfflineMessage: PropTypes.string, chatOfflineMessage: PropTypes.string,
isEncryptionDisabled: PropTypes.bool, isEncryptionDisabled: PropTypes.bool,
position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']), position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']),

View File

@ -15,6 +15,7 @@ const DEFAULT_WAIT_INTERVAL_MS = 120000; // 2 minutes
const DEFAULT_DOCK_LABEL = 'Start a new chat'; const DEFAULT_DOCK_LABEL = 'Start a new chat';
const DEFAULT_ENABLED = true; const DEFAULT_ENABLED = true;
const DEFAULT_AVAILABLE = true; const DEFAULT_AVAILABLE = true;
const DEFAULT_ENCRYPTION = 'yes';
const defaultConfig = { const defaultConfig = {
termsUrl: DEFAULT_TERMS_URL, termsUrl: DEFAULT_TERMS_URL,
@ -26,6 +27,7 @@ const defaultConfig = {
displayName: DEFAULT_DISPLAY_NAME, displayName: DEFAULT_DISPLAY_NAME,
chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE, chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE,
waitMessage: DEFAULT_WAIT_MESSAGE, waitMessage: DEFAULT_WAIT_MESSAGE,
enableEncryption: DEFAULT_ENCRYPTION,
chatOfflineMessage: DEFAULT_CHAT_OFFLINE_MESSAGE, chatOfflineMessage: DEFAULT_CHAT_OFFLINE_MESSAGE,
isEncryptionDisabled: DEFAULT_ENCRYPTION_DISABLED, isEncryptionDisabled: DEFAULT_ENCRYPTION_DISABLED,
position: DEFAULT_POSITION, position: DEFAULT_POSITION,