소스 검색

Fixes #1176

Add config setting `send_chat_state_notifications`
JC Brand 6 년 전
부모
커밋
053d4070f2
4개의 변경된 파일35개의 추가작업 그리고 20개의 파일을 삭제
  1. 1 0
      CHANGES.md
  2. 15 12
      dist/converse.js
  3. 9 1
      docs/source/configuration.rst
  4. 10 7
      src/converse-chatboxes.js

+ 1 - 0
CHANGES.md

@@ -16,6 +16,7 @@
 - M4A and WEBM files, when sent as XEP-0066 Out of Band Data, are now playable directly in chat
 - Updated French and Spanish translations
 - Two new languages supported, [Hindi](https://hosted.weblate.org/languages/hi/conversejs/) and [Romanian](https://hosted.weblate.org/languages/ro/conversejs/)
+- #1176 Add config setting [send_chat_state_notifications](https://conversejs.org/docs/html/configuration.html#send-chat-state-notifications)
 - #1187 UTF-8 characters have the wrong encoding when using OMEMO
 - #1189 Video playback failure
 - #1220 Converse not working in Edge

+ 15 - 12
dist/converse.js

@@ -59889,9 +59889,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
       // configuration settings.
 
       _converse.api.settings.update({
-        'filter_by_resource': false,
         'auto_join_private_chats': [],
-        'forward_messages': false
+        'filter_by_resource': false,
+        'forward_messages': false,
+        'send_chat_state_notifications': true
       });
 
       _converse.api.promises.add(['chatBoxesFetched', 'chatBoxesInitialized', 'privateChatsAutoJoined']);
@@ -60304,16 +60305,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
            * as taken from the 'chat_state' attribute of the chat box.
            * See XEP-0085 Chat State Notifications.
            */
-          _converse.connection.send($msg({
-            'to': this.get('jid'),
-            'type': 'chat'
-          }).c(this.get('chat_state'), {
-            'xmlns': Strophe.NS.CHATSTATES
-          }).up().c('no-store', {
-            'xmlns': Strophe.NS.HINTS
-          }).up().c('no-permanent-store', {
-            'xmlns': Strophe.NS.HINTS
-          }));
+          if (_converse.send_chat_state_notifications) {
+            _converse.connection.send($msg({
+              'to': this.get('jid'),
+              'type': 'chat'
+            }).c(this.get('chat_state'), {
+              'xmlns': Strophe.NS.CHATSTATES
+            }).up().c('no-store', {
+              'xmlns': Strophe.NS.HINTS
+            }).up().c('no-permanent-store', {
+              'xmlns': Strophe.NS.HINTS
+            }));
+          }
         },
 
         sendFiles(files) {

+ 9 - 1
docs/source/configuration.rst

@@ -1258,6 +1258,14 @@ Converse render the emojis with [Twemoji](https://twemoji.twitter.com/).
 
 See also `emoji_image_path`_.
 
+send_chat_state_notifications
+-----------------------------
+
+* Default: ``true``
+
+Determines whether chat state notifications (see `XEP-0085 <https://xmpp.org/extensions/xep-0085.html>`_)
+should be sent out or not.
+
 show_only_online_users
 ----------------------
 
@@ -1267,7 +1275,7 @@ If set to ``true``, only online users will be shown in the contacts roster.
 Users with any other status (e.g. away, busy etc.) will not be shown.
 
 show_send_button
-----------------------
+----------------
 
 * Default:  ``false``
 

+ 10 - 7
src/converse-chatboxes.js

@@ -37,9 +37,10 @@
             // Refer to docs/source/configuration.rst for explanations of these
             // configuration settings.
             _converse.api.settings.update({
-                'filter_by_resource': false,
                 'auto_join_private_chats': [],
+                'filter_by_resource': false,
                 'forward_messages': false,
+                'send_chat_state_notifications': true
             });
             _converse.api.promises.add([
                 'chatBoxesFetched',
@@ -410,12 +411,14 @@
                      * as taken from the 'chat_state' attribute of the chat box.
                      * See XEP-0085 Chat State Notifications.
                      */
-                    _converse.connection.send(
-                        $msg({'to':this.get('jid'), 'type': 'chat'})
-                            .c(this.get('chat_state'), {'xmlns': Strophe.NS.CHATSTATES}).up()
-                            .c('no-store', {'xmlns': Strophe.NS.HINTS}).up()
-                            .c('no-permanent-store', {'xmlns': Strophe.NS.HINTS})
-                    );
+                    if (_converse.send_chat_state_notifications) {
+                        _converse.connection.send(
+                            $msg({'to':this.get('jid'), 'type': 'chat'})
+                                .c(this.get('chat_state'), {'xmlns': Strophe.NS.CHATSTATES}).up()
+                                .c('no-store', {'xmlns': Strophe.NS.HINTS}).up()
+                                .c('no-permanent-store', {'xmlns': Strophe.NS.HINTS})
+                        );
+                    }
                 },