Przeglądaj źródła

Enable sending of MUC presence probes

JC Brand 5 lat temu
rodzic
commit
d49b630bdc
3 zmienionych plików z 30 dodań i 2 usunięć
  1. 2 1
      CHANGES.md
  2. 19 0
      docs/source/configuration.rst
  3. 9 1
      src/headless/converse-muc.js

+ 2 - 1
CHANGES.md

@@ -33,10 +33,11 @@ Soon we'll deprecate the latter, so prepare now.
   [discover_connection_methods](https://conversejs.org/docs/html/configuration.html#discover-connection-methods) now has a default value of `true`).
   [discover_connection_methods](https://conversejs.org/docs/html/configuration.html#discover-connection-methods) now has a default value of `true`).
 - [show_send_button](https://conversejs.org/docs/html/configuration.html#show-send-button) now has a default value of `true`.
 - [show_send_button](https://conversejs.org/docs/html/configuration.html#show-send-button) now has a default value of `true`.
 - The [api.confirm](https://conversejs.org/docs/html/api/-_converse.api.html#.confirm) method now accepts a list of fields and returns the filled in list upon confirmation.
 - The [api.confirm](https://conversejs.org/docs/html/api/-_converse.api.html#.confirm) method now accepts a list of fields and returns the filled in list upon confirmation.
+- New config option [allow_adhoc_commands](https://conversejs.org/docs/html/configuration.html#allow-adhoc-commands)
 - New config option [modtools_disable_assign](https://conversejs.org/docs/html/configuration.html#modtools-disable-assign)
 - New config option [modtools_disable_assign](https://conversejs.org/docs/html/configuration.html#modtools-disable-assign)
 - New config option [modtools_disable_query](https://conversejs.org/docs/html/configuration.html#modtools-disable-query)
 - New config option [modtools_disable_query](https://conversejs.org/docs/html/configuration.html#modtools-disable-query)
-- New config option [allow_adhoc_commands](https://conversejs.org/docs/html/configuration.html#allow-adhoc-commands)
 - New config option [muc_hats_from_vcard](https://conversejs.org/docs/html/configuration.html#muc-hats-from-vcard).
 - New config option [muc_hats_from_vcard](https://conversejs.org/docs/html/configuration.html#muc-hats-from-vcard).
+- New config option [muc_send_probes](https://conversejs.org/docs/html/configuration.html#muc-send-probes).
 
 
 ## 6.0.0 (2020-01-09)
 ## 6.0.0 (2020-01-09)
 
 

+ 19 - 0
docs/source/configuration.rst

@@ -1181,6 +1181,25 @@ automatically be "john". If now john@differentdomain.com tries to join the
 room, his nickname will be "john-2", and if john@somethingelse.com joins, then
 room, his nickname will be "john-2", and if john@somethingelse.com joins, then
 his nickname will be "john-3", and so forth.
 his nickname will be "john-3", and so forth.
 
 
+muc_send_probes
+---------------
+
+* Default: ``false``
+
+If set to ``true``,  then whenever Converse receives a MUC message with an author for which we don't have
+any information (i.e. because that user is currently not in the MUC), then Converse will send out a ``<presence>``
+stanza of type ``probe`` in order to request the authors presence data.
+
+Note, although this behavior is described in the `presence business rules of XEP-0045, section 17.3 point 4 <https://xmpp.org/extensions/xep-0045.html#bizrules-presence>`_,
+few XMPP servers support this.
+
+Prosody has some experimental support in it's contrib branch (hopefully soon to
+be merged to trunk).
+
+The point of sending out presence probes is in order to receive
+presence-related metadata, such as `XEP-0317 Hats <https://xmpp.org/extensions/xep-0317.html>`_.
+
+
 muc_respect_autojoin
 muc_respect_autojoin
 --------------------
 --------------------
 
 

+ 9 - 1
src/headless/converse-muc.js

@@ -125,6 +125,7 @@ converse.plugins.add('converse-muc', {
             'muc_history_max_stanzas': undefined,
             'muc_history_max_stanzas': undefined,
             'muc_instant_rooms': true,
             'muc_instant_rooms': true,
             'muc_nickname_from_jid': false,
             'muc_nickname_from_jid': false,
+            'muc_send_probes': false,
             'muc_show_join_leave': true,
             'muc_show_join_leave': true,
             'muc_show_logs_before_join': false
             'muc_show_logs_before_join': false
         });
         });
@@ -305,7 +306,14 @@ converse.plugins.add('converse-muc', {
                     return log.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);
                     return log.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);
                 }
                 }
                 const nick = Strophe.getResourceFromJid(this.get('from'));
                 const nick = Strophe.getResourceFromJid(this.get('from'));
-                this.occupant = chatbox.occupants.findWhere({'nick': nick});
+                this.occupant = chatbox.occupants.findWhere({ nick });
+
+                if (!this.occupant && api.settings.get("muc_send_probes")) {
+                    this.occupant = chatbox.occupants.create({ nick, 'type': 'unavailable' });
+                    const jid = `${chatbox.get('jid')}/${nick}`;
+                    api.user.presence.send('probe', jid);
+                }
+
                 if (this.occupant) {
                 if (this.occupant) {
                     this.listenTo(this.occupant, 'destroy', this.onOccupantRemoved);
                     this.listenTo(this.occupant, 'destroy', this.onOccupantRemoved);
                 } else {
                 } else {