mod_pubsub: Fix inclusion of publisher (fixes #1399)

This commit is contained in:
Kim Alvefur 2019-05-01 22:33:22 +02:00
parent a399b1caed
commit 23dbdae2aa
6 changed files with 20 additions and 17 deletions

View file

@ -607,6 +607,9 @@ function handlers.set_publish(origin, stanza, publish, service)
item.attr.id = id;
end
end
if item then
item.attr.publisher = service.config.normalize_jid(stanza.attr.from);
end
local ok, ret = service:publish(node, stanza.attr.from, id, item, required_config);
local reply;
if ok then
@ -795,8 +798,8 @@ function handlers.owner_set_affiliations(origin, stanza, affiliations, service)
return true;
end
local function create_encapsulating_item(id, payload)
local item = st.stanza("item", { id = id, xmlns = xmlns_pubsub });
local function create_encapsulating_item(id, payload, publisher)
local item = st.stanza("item", { id = id, publisher = publisher, xmlns = xmlns_pubsub });
item:add_child(payload);
return item;
end

View file

@ -1,7 +1,7 @@
# Publishing a nickname in PEP and receiving a notification
[Client] Romeo
jid: romeo@localhost/nJi7BeTR
jid: romeo@localhost
password: password
-----
@ -20,7 +20,7 @@ Romeo sends:
</iq>
Romeo receives:
<iq id="4" to="romeo@localhost/nJi7BeTR" type="result">
<iq id="4" type="result">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<publish node="http://jabber.org/protocol/nick">
<item id="current"/>
@ -34,12 +34,12 @@ Romeo sends:
</presence>
Romeo receives:
<iq id="disco" to="romeo@localhost/nJi7BeTR" from="romeo@localhost" type="get">
<iq id="disco" from="romeo@localhost" type="get">
<query xmlns="http://jabber.org/protocol/disco#info" node="http://code.matthewwild.co.uk/clix/#jC32N+FhQoLrZ7nNQtZK3aqR0Fk="/>
</iq>
Romeo receives:
<presence from="romeo@localhost/nJi7BeTR">
<presence>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.matthewwild.co.uk/clix/" ver="jC32N+FhQoLrZ7nNQtZK3aqR0Fk="/>
</presence>
@ -55,10 +55,10 @@ Romeo sends:
</iq>
Romeo receives:
<message type="headline" from="romeo@localhost" to="romeo@localhost/nJi7BeTR">
<message type="headline" from="romeo@localhost">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="http://jabber.org/protocol/nick">
<item id="current">
<item id="current" publisher="${Romeo's JID}">
<nickname xmlns="http://jabber.org/protocol/nick"/>
</item>
</items>

View file

@ -182,7 +182,7 @@ Juliet sends:
<iq type='result' id='fixme'/>
Juliet sends:
<iq type='set' id='7'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='http://jabber.org/protocol/tune'><item id='current'><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></publish></pubsub></iq>
<iq type='set' id='7'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='http://jabber.org/protocol/tune'><item id='current' publisher="${Juliet's JID}"><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></publish></pubsub></iq>
Juliet receives:
<iq type='result' id='7' ><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='http://jabber.org/protocol/tune'><item id='current'/></publish></pubsub></iq>
@ -197,13 +197,13 @@ Juliet sends:
<iq type='result' id='{scansion:any}'/>
Romeo receives:
<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current'><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current' publisher="${Juliet's JID}"><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
Romeo sends:
<iq type='result' id='disco' to='pep-test-tqvqu_pv@localhost'><query xmlns='http://jabber.org/protocol/disco#info' node='http://code.matthewwild.co.uk/verse/#IfQwbaaDB4LEP5tkGArEaB/3Y+s='><identity type='pc' name='Verse' category='client'/><feature var='http://jabber.org/protocol/tune+notify'/><feature var='http://jabber.org/protocol/disco#info'/><feature var='http://jabber.org/protocol/disco#items'/><feature var='http://jabber.org/protocol/caps'/><feature var='http://jabber.org/protocol/mood+notify'/></query></iq>
Romeo receives:
<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current'><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current' publisher="${Juliet's JID}"><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
Juliet disconnects

View file

@ -129,7 +129,7 @@ Juliet receives:
<message type="headline" from="pubsub.localhost">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="princely_musings">
<item id="current">
<item id="current" publisher="${Romeo's JID}">
<entry xmlns="http://www.w3.org/2005/Atom">
<title>Soliloquy</title>
<summary>Lorem ipsum dolor sit amet</summary>

View file

@ -67,7 +67,7 @@ Juliet receives:
<message type="headline" from="pubsub.localhost">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="princely_musings">
<item id="current">
<item id="current" publisher="${Romeo's JID}">
<entry xmlns="http://www.w3.org/2005/Atom">
<title>Soliloquy</title>
<summary>Lorem ipsum dolor sit amet</summary>

View file

@ -159,10 +159,10 @@ Alice receives:
<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":3nvB2E20p1iuM6lOPaP6">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node="e96caf12-264f-4e5a-988e-00ae191771b6">
<item xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
<item publisher="${Alice's JID}" xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo>
</item>
<item xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557">
<item publisher="${Alice's JID}" xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557">
<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo>
</item>
</items>
@ -180,10 +180,10 @@ Alice receives:
<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":XQdyK54iyOKiJvUoX9t_">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node="e96caf12-264f-4e5a-988e-00ae191771b6">
<item xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
<item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo>
</item>
<item xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557">
<item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="4b94623d-1127-41c0-ac47-e283fd890557">
<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo>
</item>
</items>