From 3c5280119357e3742811fd724601d0bef01bcb29 Mon Sep 17 00:00:00 2001
From: David Meza <dmeza@users.noreply.github.com>
Date: Fri, 1 Sep 2017 08:53:55 -0500
Subject: Config to make town square read only (#7140)

* Be able to make Town Square read-only (Disable typing messages for non admins).

* Do not emit UserTypingEvent when TownSquareIsReadOnly and is Town Square.

* Add unit tests for TownSquareIsReadOnly config value and logic.

* Add TownSquareIsReadOnly to System console>Policy. Added Telemetry.

* Add control for TownSquareIsReadOnly=true only for License Enterprise Edition E10 & E20.

* Update en.json

* Update en.json

* Update policy_settings.jsx

* Change config value from TownSquareIsReadOnly to ExperimentalTownSquareIsReadOnly.

* Refactored to simplify. Avoid code repeat and multiple db calls.
---
 webapp/actions/global_actions.jsx | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'webapp/actions/global_actions.jsx')

diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index a67d1b751..025e56f7d 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -443,6 +443,13 @@ export function emitLocalUserTypingEvent(channelId, parentId) {
     const t = Date.now();
     const membersInChannel = ChannelStore.getStats(channelId).member_count;
 
+    if (global.mm_license.IsLicensed === 'true' && global.mm_config.ExperimentalTownSquareIsReadOnly === 'true') {
+        const channel = ChannelStore.getChannelById(channelId);
+        if (channel && ChannelStore.isDefault(channel)) {
+            return;
+        }
+    }
+
     if (((t - lastTimeTypingSent) > global.window.mm_config.TimeBetweenUserTypingUpdatesMilliseconds) && membersInChannel < global.window.mm_config.MaxNotificationsPerChannel && global.window.mm_config.EnableUserTypingMessages === 'true') {
         WebSocketClient.userTyping(channelId, parentId);
         lastTimeTypingSent = t;
-- 
cgit v1.2.3-1-g7c22

