diff --git a/CHANGELOG.md b/CHANGELOG.md
index a82afd0136d..e64c5a83944 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
### Notable enhancements and fixes
+* New `enableIntegratedChat` setting makes it possible to completely disable the
+ built-in chat feature (not just hide it).
* Improvements to login session management:
* `express_sid` cookies and `sessionstorage:*` database records are no longer
created unless `requireAuthentication` is `true` (or a plugin causes them to
diff --git a/doc/docker.md b/doc/docker.md
index f72c4dd666b..093a260768f 100644
--- a/doc/docker.md
+++ b/doc/docker.md
@@ -80,15 +80,16 @@ The `settings.json.docker` available by default allows to control almost every s
### General
-| Variable | Description | Default |
-| ------------------ | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `TITLE` | The name of the instance | `Etherpad` |
-| `FAVICON` | favicon default name, or a fully specified URL to your own favicon | `favicon.ico` |
-| `DEFAULT_PAD_TEXT` | The default text of a pad | `Welcome to Etherpad! This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents! Get involved with Etherpad at https://etherpad.org` |
-| `IP` | IP which etherpad should bind at. Change to `::` for IPv6 | `0.0.0.0` |
-| `PORT` | port which etherpad should bind at | `9001` |
-| `ADMIN_PASSWORD` | the password for the `admin` user (leave unspecified if you do not want to create it) | |
-| `USER_PASSWORD` | the password for the first user `user` (leave unspecified if you do not want to create it) | |
+| Variable | Description | Default |
+| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `TITLE` | The name of the instance | `Etherpad` |
+| `FAVICON` | favicon default name, or a fully specified URL to your own favicon | `favicon.ico` |
+| `DEFAULT_PAD_TEXT` | The default text of a pad | `Welcome to Etherpad! This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents! Get involved with Etherpad at https://etherpad.org` |
+| `ENABLE_INTEGRATED_CHAT` | Whether to enable the built-in chat feature. Set this to false if you prefer to use a plugin to provide chat functionality or simply do not want the feature. | true |
+| `IP` | IP which etherpad should bind at. Change to `::` for IPv6 | `0.0.0.0` |
+| `PORT` | port which etherpad should bind at | `9001` |
+| `ADMIN_PASSWORD` | the password for the `admin` user (leave unspecified if you do not want to create it) | |
+| `USER_PASSWORD` | the password for the first user `user` (leave unspecified if you do not want to create it) | |
### Database
diff --git a/settings.json.docker b/settings.json.docker
index 725af9f314c..d1679d7da73 100644
--- a/settings.json.docker
+++ b/settings.json.docker
@@ -223,6 +223,13 @@
*/
"defaultPadText" : "${DEFAULT_PAD_TEXT:Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at https:\/\/etherpad.org\n}",
+ /*
+ * Whether to enable the built-in chat feature. Set this to false if you
+ * prefer to use a plugin to provide chat functionality or simply do not want
+ * the feature.
+ */
+ "enableIntegratedChat": "${ENABLE_INTEGRATED_CHAT:true}",
+
/*
* Default Pad behavior.
*
@@ -231,6 +238,7 @@
"padOptions": {
"noColors": "${PAD_OPTIONS_NO_COLORS:false}",
"showControls": "${PAD_OPTIONS_SHOW_CONTROLS:true}",
+ // To completely disable chat, set enableIntegratedChat to false.
"showChat": "${PAD_OPTIONS_SHOW_CHAT:true}",
"showLineNumbers": "${PAD_OPTIONS_SHOW_LINE_NUMBERS:true}",
"useMonospaceFont": "${PAD_OPTIONS_USE_MONOSPACE_FONT:false}",
diff --git a/settings.json.template b/settings.json.template
index b2cb9555a6c..446ddb882a8 100644
--- a/settings.json.template
+++ b/settings.json.template
@@ -224,6 +224,13 @@
*/
"defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at https:\/\/etherpad.org\n",
+ /*
+ * Whether to enable the built-in chat feature. Set this to false if you
+ * prefer to use a plugin to provide chat functionality or simply do not want
+ * the feature.
+ */
+ "enableIntegratedChat": true,
+
/*
* Default Pad behavior.
*
@@ -232,6 +239,7 @@
"padOptions": {
"noColors": false,
"showControls": true,
+ // To completely disable chat, set enableIntegratedChat to false.
"showChat": true,
"showLineNumbers": true,
"useMonospaceFont": false,
diff --git a/src/ep.json b/src/ep.json
index 7c76b4dd766..6fb110f5e6b 100644
--- a/src/ep.json
+++ b/src/ep.json
@@ -28,7 +28,12 @@
"padCheck": "ep_etherpad-lite/node/chat",
"padCopy": "ep_etherpad-lite/node/chat",
"padLoad": "ep_etherpad-lite/node/chat",
- "padRemove": "ep_etherpad-lite/node/chat",
+ "padRemove": "ep_etherpad-lite/node/chat"
+ }
+ },
+ {
+ "name": "chatAlwaysLoaded",
+ "hooks": {
"socketio": "ep_etherpad-lite/node/chat"
}
},
diff --git a/src/node/chat.js b/src/node/chat.js
index dc9f0ef1744..768e74b2e2b 100644
--- a/src/node/chat.js
+++ b/src/node/chat.js
@@ -10,10 +10,14 @@ const pad = require('./db/Pad');
const padManager = require('./db/PadManager');
const padMessageHandler = require('./handler/PadMessageHandler');
const promises = require('./utils/promises');
+const settings = require('./utils/Settings');
let socketio;
const appendChatMessage = async (pad, msg) => {
+ if (!settings.enableIntegratedChat) {
+ throw new Error('integrated chat is disabled (see enableIntegratedChat in settings.json)');
+ }
pad.chatHead++;
await Promise.all([
// Don't save the display name in the database because the user can change it at any time. The
@@ -25,6 +29,9 @@ const appendChatMessage = async (pad, msg) => {
};
const getChatMessage = async (pad, entryNum) => {
+ if (!settings.enableIntegratedChat) {
+ throw new Error('integrated chat is disabled (see enableIntegratedChat in settings.json)');
+ }
const entry = await pad.db.get(`pad:${pad.id}:chat:${entryNum}`);
if (entry == null) return null;
const message = ChatMessage.fromObject(entry);
@@ -33,6 +40,9 @@ const getChatMessage = async (pad, entryNum) => {
};
const getChatMessages = async (pad, start, end) => {
+ if (!settings.enableIntegratedChat) {
+ throw new Error('integrated chat is disabled (see enableIntegratedChat in settings.json)');
+ }
const entries = await Promise.all(
[...Array(end + 1 - start).keys()].map((i) => getChatMessage(pad, start + i)));
@@ -49,6 +59,9 @@ const getChatMessages = async (pad, start, end) => {
};
const sendChatMessageToPadClients = async (message, padId) => {
+ if (!settings.enableIntegratedChat) {
+ throw new Error('integrated chat is disabled (see enableIntegratedChat in settings.json)');
+ }
const pad = await padManager.getPad(padId, null, message.authorId);
await hooks.aCallAll('chatNewMessage', {message, pad, padId});
// appendChatMessage() ignores the displayName property so we don't need to wait for
@@ -65,6 +78,7 @@ const sendChatMessageToPadClients = async (message, padId) => {
exports.clientVars = (hookName, {pad: {chatHead}}) => ({chatHead});
exports.eejsBlock_mySettings = (hookName, context) => {
+ if (!settings.enableIntegratedChat) return;
context.content += `