diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6815d681d..30011e081 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
### Notable enhancements and fixes
+* New `integratedChat` 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 f72c4dd66..7e57feb44 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` |
+| `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 725af9f31..58a56affc 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.
+ */
+ "integratedChat": "${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 integratedChat 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 b2cb9555a..59e6c2e0a 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.
+ */
+ "integratedChat": true,
+
/*
* Default Pad behavior.
*
@@ -232,6 +239,7 @@
"padOptions": {
"noColors": false,
"showControls": true,
+ // To completely disable chat, set integratedChat to false.
"showChat": true,
"showLineNumbers": true,
"useMonospaceFont": false,
diff --git a/src/ep.json b/src/ep.json
index e8ca7f956..4c78e2e0d 100644
--- a/src/ep.json
+++ b/src/ep.json
@@ -30,7 +30,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 8bab29702..ec1d6ce8e 100644
--- a/src/node/chat.js
+++ b/src/node/chat.js
@@ -10,10 +10,14 @@ const hooks = require('../static/js/pluginfw/hooks.js');
const pad = require('./db/Pad');
const padManager = require('./db/PadManager');
const padMessageHandler = require('./handler/PadMessageHandler');
+const settings = require('./utils/Settings');
let socketio;
const appendChatMessage = async (pad, msg) => {
+ if (!settings.integratedChat) {
+ throw new Error('integrated chat is disabled (see integratedChat 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.integratedChat) {
+ throw new Error('integrated chat is disabled (see integratedChat 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.integratedChat) {
+ throw new Error('integrated chat is disabled (see integratedChat 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.integratedChat) {
+ throw new Error('integrated chat is disabled (see integratedChat 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.integratedChat) return;
context.content += `