I'm using ejabberd as a chat server. When I send the request
(example from http://xmpp.org/extensions/xep-0048.html#storage-pubsub-upload)
<iq from='juliet@capulet.lit/balcony' type='set' id='pip1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='storage:bookmarks'>
<item id='current'>
<storage xmlns='storage:bookmarks'>
<conference name='The Play's the Thing'
autojoin='true'
jid='theplay@conference.shakespeare.lit'>
<nick>JC</nick>
</conference>
</storage>
</item>
</publish>
<publish-options>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#publish-options</value>
</field>
<field var='pubsub#persist_items'>
<value>true</value>
</field>
<field var='pubsub#access_model'>
<value>whitelist</value>
</field>
</x>
</publish-options>
</pubsub>
</iq>
PubSub configuration:
mod_pubsub:
db_type: odbc
access_createnode: pubsub_createnode
## reduces resource comsumption, but XEP incompliant
ignore_pep_from_offline: true
## XEP compliant, but increases resource comsumption
## ignore_pep_from_offline: false
last_item_cache: false
plugins:
- "flat"
- "hometree"
- "pep" # pep requires mod_caps
It works fine. But if I send a similar request to store a different chat room it replaces this one. Even if I change the item "id". Any ideas on how to store multiple conferences?
The Bookmarks specification is leveraging Personal Eventing Protocol. The assumption we made for PEP in ejabberd with default configuration is the the number of kept items on those special PubSub nodes is '1'.
You can check this by sending the following node configuration request:
<iq type='get'
id='config1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
<configure node='storage:bookmarks'/>
</pubsub>
</iq>
You will see that the reply shows that max number of items is '1':
<iq from="mremond@localhost" type="result" to="mremond@localhost/MacBook-Pro-de-Mickael" id="config1">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
<configure node="storage:bookmarks">
<x xmlns="jabber:x:data" type="form">
...
<field type="text-single" label="Max # of items to persist" var="pubsub#max_items">
<value>1</value>
</field>
...
</x>
</configure>
</pubsub>
</iq>
It means indeed that you are expected to have only one bookmark set. However, it does not prevent you from storing several bookmarks in the same set, as follow:
<iq type='set' id='pip1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='storage:bookmarks'>
<item id='current'>
<storage xmlns='storage:bookmarks'>
<conference name='Bookmark1'
autojoin='false'
jid='room1@conference.shakespeare.lit'>
<nick>Mynick1</nick>
</conference>
<conference name='Bookmark2'
autojoin='true'
jid='room2@conference.shakespeare.lit'>
<nick>Mynick2</nick>
</conference>
</storage>
</item>
</publish>
<publish-options>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#publish-options</value>
</field>
<field var='pubsub#persist_items'>
<value>true</value>
</field>
<field var='pubsub#access_model'>
<value>whitelist</value>
</field>
</x>
</publish-options>
</pubsub>
</iq>
ejabberd will reply with success:
<iq from="mremond@localhost" type="result" to="mremond@localhost/MacBook-Pro-de-Mickael" id="pip1">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<publish node="storage:bookmarks">
<item id="current"/>
</publish>
</pubsub>
</iq>
You can then query your bookmark and check that you have two bookmarks in that bookmark set:
<iq type='get' id='retrieve1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='storage:bookmarks'/>
</pubsub>
</iq>
and response is:
<iq from="mremond@localhost" type="result" to="mremond@localhost/MacBook-Pro-de-Mickael" id="retrieve1">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node="storage:bookmarks">
<item id="current">
<storage xmlns="storage:bookmarks">
<conference name="Bookmark1" autojoin="false" jid="room1@conference.shakespeare.lit">
<nick>Mynick1</nick>
</conference>
<conference name="Bookmark2" autojoin="true" jid="room2@conference.shakespeare.lit">
<nick>Mynick2</nick>
</conference>
</storage>
</item>
</items>
</pubsub>
</iq>
You can store several bookmarks in the same set. Just upload all of them at once. So, to update the bookmark set, you are supposed to read it first and then store the updated version, not send incremental changes.
That said, I read the spec several times (XEP-0048 Bookmarks and XEP-0163 PEP). I do not see example or reference regarding the number of items on a PEP node. All the examples show only one item. The goal of PEP being to broadcast updates of a state. The assumption in most of the specification is that there is only one item involved (One avatar, one geoloc, etc). However, we would be happy to revise our assumption if we can find explicit element in the specification about the number of items that can be used.