Currently, if auto_request is enabled, sleekxmpp will add a to each outgoing message stanza which is either 'normal', 'chat', or 'headline'.
However, this means that some messages will have receipt requests, even though they are kind of useless (in my opinion, at least), and the sender will still ack them, which might not be ideal, e.g. in a mobile, resource-constrained environment. The main offender here are chat states.
My suggestion is either to require a message to have a body for adding a request element:
--- a/sleekxmpp/plugins/xep_0184/receipt.py
+++ b/sleekxmpp/plugins/xep_0184/receipt.py
@@ -118,6 +118,9 @@ class XEP_0184(BasePlugin):
if stanza['receipt']:
return stanza
+ if not stanza['body']:
+ return stanza
+
if stanza['to'].resource:
if not self.xmpp['xep_0030'].supports(stanza['to'],
feature='urn:xmpp:receipts',
Or let the developer set an additional filter to the plugin in order to only match stanzas they want to add receipts to:
--- a/sleekxmpp/plugins/xep_0184/receipt.py
+++ b/sleekxmpp/plugins/xep_0184/receipt.py
@@ -28,7 +28,8 @@ class XEP_0184(BasePlugin):
stanza = stanza
default_config = {
'auto_ack': True,
- 'auto_request': False
+ 'auto_request': False,
+ 'filter': None,
}
ack_types = ('normal', 'chat', 'headline')
@@ -118,6 +119,9 @@ class XEP_0184(BasePlugin):
if stanza['receipt']:
return stanza
+ if self.filter and not self.filter(stanza):
+ return stanza
+
if stanza['to'].resource:
if not self.xmpp['xep_0030'].supports(stanza['to'],
feature='urn:xmpp:receipts',
Currently, if auto_request is enabled, sleekxmpp will add a to each outgoing message stanza which is either 'normal', 'chat', or 'headline'.
However, this means that some messages will have receipt requests, even though they are kind of useless (in my opinion, at least), and the sender will still ack them, which might not be ideal, e.g. in a mobile, resource-constrained environment. The main offender here are chat states.
My suggestion is either to require a message to have a body for adding a request element:
Or let the developer set an additional filter to the plugin in order to only match stanzas they want to add receipts to: