Skip to content

Instantly share code, notes, and snippets.

@ivucica
Last active February 5, 2021 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivucica/8e0286a44b300da5fc2e25cee52d0bad to your computer and use it in GitHub Desktop.
Save ivucica/8e0286a44b300da5fc2e25cee52d0bad to your computer and use it in GitHub Desktop.
Prosody: <x/> placed as its own child of <item/> instead of being a child of <notification/>
From MattJ.
diff --git a/mod_cloud_notify/mod_cloud_notify.lua b/mod_cloud_notify/mod_cloud_notify.lua
--- a/mod_cloud_notify/mod_cloud_notify.lua
+++ b/mod_cloud_notify/mod_cloud_notify.lua
@@ -337,12 +337,13 @@ local function handle_notify_request(sta
form_data["last-message-body"] = tostring(dummy_body);
end
+ push_notification_payload:add_child(push_form:form(form_data));
+
local push_publish = st.iq({ to = push_info.jid, from = module.host, type = "set", id = stanza_id })
:tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" })
:tag("publish", { node = push_info.node })
:tag("item")
:add_child(push_notification_payload)
- :add_child(push_form:form(form_data))
:up()
:up();
Note: Not a proper patch because push_notification_payload is used a few lines below, and yet,
this is *not* actually updating it, but *working around it*. Beware of dragons.
diff -r d7f104cff332 mod_cloud_notify/mod_cloud_notify.lua
--- a/mod_cloud_notify/mod_cloud_notify.lua Wed Feb 03 17:35:52 2021 +0000
+++ b/mod_cloud_notify/mod_cloud_notify.lua Fri Feb 05 12:22:31 2021 +0000
@@ -341,8 +341,9 @@
:tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" })
:tag("publish", { node = push_info.node })
:tag("item")
- :add_child(push_notification_payload)
- :add_child(push_form:form(form_data))
+ :tag("notification", { xmlns = xmlns_push })
+ :add_child(push_form:form(form_data))
+ :up()
:up()
:up();
<iq from='MY_DOMAIN' to='push.tigase.im' type='set' id='SNIP'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='OMITTING NODE'>
<item>
<notification xmlns='urn:xmpp:push:0'/>
<x xmlns='jabber:x:data' type='form'>
<field var='FORM_TYPE' type='hidden'>
<value>urn:xmpp:push:summary</value>
</field>
<field var='message-count' type='text-single'>
<value>1</value>
</field>
<field var='pending-subscription-count' type='text-single'/>
<field var='last-message-sender' type='jid-single'>
<value>OMITTING@SENDER/ANDRESOURCE</value>
</field>
<field var='last-message-body' type='text-single'/>
</x>
</item>
</publish>
</pubsub>
</iq>
<iq from='MY_DOMAIN' to='push.tigase.im' type='set' id='SNIP'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='OMITTING NODE'>
<item>
<notification xmlns='urn:xmpp:push:0'>
<x xmlns='jabber:x:data' type='form'>
<field var='FORM_TYPE' type='hidden'>
<value>urn:xmpp:push:summary</value>
</field>
<field var='message-count' type='text-single'>
<value>1</value>
</field>
<field var='pending-subscription-count' type='text-single'/>
<field var='last-message-sender' type='jid-single'>
<value>OMITTING@SENDER/ANDRESOURCE</value>
</field>
<field var='last-message-body' type='text-single'/>
</x>
</notification>
</item>
</publish>
</pubsub>
</iq>
<iq type='set'
from='example.com'
to='push-5.client.example'
id='n12'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='yxs32uqsflafdk3iuqo'>
<item>
<notification xmlns='urn:xmpp:push:0'>
<x xmlns='jabber:x:data'>
<field var='FORM_TYPE'><value>urn:xmpp:push:summary</value></field>
<field var='message-count'><value>1</value></field>
<field var='last-message-sender'><value>juliet@capulet.example/balcony</value></field>
<field var='last-message-body'><value>Wherefore art thou, Romeo?</value></field>
</x>
<additional xmlns='http://example.com/custom'>Additional custom elements</additional>
</notification>
</item>
</publissenth>
</pubsub>
</iq>
@ivucica
Copy link
Author

ivucica commented Feb 5, 2021

Possibly related to https://issues.prosody.im/1544

@ivucica
Copy link
Author

ivucica commented Feb 5, 2021

0.11.7 + prosody_modules b3e0295e14a3 (Wed Feb 03 18:03:12 2021 +0100):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment