浏览代码

Add new config setting enable_muc_push

JC Brand 6 年之前
父节点
当前提交
8c391fe067
共有 3 个文件被更改,包括 23 次插入4 次删除
  1. 2 1
      CHANGES.md
  2. 15 0
      docs/source/configuration.rst
  3. 6 3
      src/converse-push.js

+ 2 - 1
CHANGES.md

@@ -2,7 +2,8 @@
 
 ## 4.0.1 (Unreleased)
 
-- New configuration setting [auto_register_muc_nickname](https://conversejs.org/docs/html/configuration.html#auto-register-muc-nickname)
+- New config  setting [auto_register_muc_nickname](https://conversejs.org/docs/html/configuration.html#auto-register-muc-nickname)
+- New config setting [enable_muc_push](https://conversejs.org/docs/html/configuration.html#enable-muc-push)
 - #1182 MUC occupants without nick or JID created
 - #1184 Notification error when message has no body
 

+ 15 - 0
docs/source/configuration.rst

@@ -630,6 +630,21 @@ If you've run ``make dev``, then these files are also available in ``./node_modu
 which means you can avoid the CDN and host them yourself if you wish.
 
 
+enable_muc_push
+---------------
+
+* Default: ``false``
+
+If true, then Converse will try to register
+`XEP-0357 push notification App Server(s) <https://xmpp.org/extensions/xep-0357.html#general-architecture>`_
+for the MUC domain of any newly entered groupchat.
+
+The app servers are specified with the `push_app_servers`_ option.
+
+.. note::
+    Registering a push app server against a MUC domain is not (yet) standardized
+    and this feature should be considered experimental.
+
 expose_rid_and_sid
 ------------------
 

+ 6 - 3
src/converse-push.js

@@ -28,6 +28,7 @@
 
             _converse.api.settings.update({
                 'push_app_servers': [],
+                'enable_muc_push': false
             });
 
             async function disablePushAppServer (domain, push_app_server) {
@@ -119,14 +120,16 @@
                 _converse.session.save('push_enabled', push_enabled);
             }
 
+            _converse.api.listen.on('statusInitialized', () => enablePush());
+
             function onChatBoxAdded (model) {
                 if (model.get('type') == _converse.CHATROOMS_TYPE) {
                     enablePush(Strophe.getDomainFromJid(model.get('jid')));
                 }
             }
-
-            _converse.api.listen.on('statusInitialized', () => enablePush());
-            _converse.api.listen.on('chatBoxesInitialized',  () => _converse.chatboxes.on('add', onChatBoxAdded));
+            if (_converse.enable_muc_push) {
+                _converse.api.listen.on('chatBoxesInitialized',  () => _converse.chatboxes.on('add', onChatBoxAdded));
+            }
         }
     });
 }));