XEP-0222, XEP-0223 (Persistent Storage via PubSub) support
Depends on #44.
XEP-0222 (Persistent Storage of Public Data via PubSub) XEP-0223 (Persistent Storage of Private Data via PubSub)
@sebastianriese We’ve had ejabberd in our CI test enviroment for a while now. I think we should tackle this for the 0.11 milestone.
Agreed. (Shouldn't prosody trunk also support this by now.)
Prosody trunk now has full support for Private/Public persistent PEP. I built support for specifying access_model in aioxmpp.PEPClient.publish. We should discuss the API for PEP-based storage.
I’m thinking of subclassing the claim PEP node descriptor with two subclasses:
- MultiItemPEPStorage which is used for things like Bookmarks 2 and provides an interface to list items in the node, delete items, add items etc.
- SingleItemPEPStorage which is used for most other PEP based stores where all data is crammed in a single item. It forces the ID to be "current" according to XEP-0060 singleton use and offers fetch, put and an on_changed event.
A using service would then do something like this:
class BookmarksService(...):
xep0084_node = MultiItemPEPStorage(node="storage:bookmarks", private=True)
xep0402_node = MultiItemPEPStorage(node="urn:xmpp:bookmarks:0", private=True)
async def fetch_items(self):
return join_the_items(old=(await self.xep0084_node.fetch()), new=(await self.xep0402_node.fetch()))
Questions:
- Do we really want to support storage:bookmarks in a single pubsub node (interoperability with other clients)? It is extra work and probably not worth the hassle.
- Do we offer the possibility to sync the bookmarks between pubsub/privatexml storage?
For the time being, we’ll have to support single-item storage:bookmarks in PEP. The reason is that Bookmarks 2 isn’t supported yet by servers for auto-conversion and it’s also not supported by other clients.
Regarding the sync, I suggest that we do the following:
- If the server offers the
urn:xmpp:bookmarks-conversion:0feature on the account, we pick the PEP Single Item based implementation, because it gives us notification support. - If the server does not offer the feature, we check both PEP and Private stores on the first interaction with the storage. If both stores are non-empty, we bail out with a
RuntimeError("multiple storage backends for bookmarks are in use and sync is not supported") - If one of the stores is non-empty, we pick the store which is non-empty.
- If both stores are empty, we prefer single-item PEP.