aioxmpp icon indicating copy to clipboard operation
aioxmpp copied to clipboard

XEP-0222, XEP-0223 (Persistent Storage via PubSub) support

Open horazont opened this issue 9 years ago • 5 comments

Depends on #44.

XEP-0222 (Persistent Storage of Public Data via PubSub) XEP-0223 (Persistent Storage of Private Data via PubSub)

horazont avatar Feb 26 '17 15:02 horazont

@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.

horazont avatar Jul 09 '18 11:07 horazont

Agreed. (Shouldn't prosody trunk also support this by now.)

sebastianriese avatar Jul 09 '18 11:07 sebastianriese

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()))

horazont avatar Aug 06 '18 18:08 horazont

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?

sebastianriese avatar Nov 08 '18 01:11 sebastianriese

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:0 feature 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.

horazont avatar Nov 08 '18 15:11 horazont