[ejabberd] Patch: XEP-0248 support for mod_pubsub

Brian Cully bcully at gmail.com
Thu Dec 11 22:17:18 MSK 2008


[Original message bounced as too big, so I'm posting the information  
to the list, and the patch is in p1's ticket tracking system at: https://support.process-one.net/browse/EJAB-815 
  -bjc]

	As promised, I put together a good chunk of support for XEP-0248. The  
relevant details are below. There are a couple things I couldn't do  
which I would have liked to except that it would break API  
compatibility.

	There's no support for subscription options, which is a shame, as  
they would be very useful, this can probably be worked around with the  
addition of another call to node modules (get_subscription(Host, Node,  
JID)), which is relatively minor. There's also no support for  
subscription depth, and I have to default to 'all'. This is because  
the get_states/2 function in node modules returns a #pubsub_state  
object which has no place for a "depth". It might be reasonable to  
shoehorn that into get_subscription (by backfilling subs as children  
are added), but it's really better in the return from get_states/2.

	All nodes start with "/", even ones you create with another leading  
character. It causes no real harm unless you're being anal retentive  
about your results. It might be a little confusing. This is because  
nodes are assumed in a number of places to be "/" separated, and  
fixing that is painful for the payoff. One possibility opens up if  
these patches are accepted: we can do away with the separation (giving  
us XEP compliance) by using XEP-0248 support which would then be baked  
in.

	There's no notice of associations and dissociations. I'd like to do  
this, but supporting it requires a small API modification with  
nodetree modules. mod_pubsub needs to know when a config change  
results in a DAG change, but currently calls can't return that  
information.

	Questions? Comments?

-bjc

My commit log:

Add a good chunk of support for XEP-0248.

   * No schema changes. The only change you might need to care about is
     the one for node_default marked 'API-CHANGE'.

   * Notifications can be delivered via collection nodes. These
     notifications are distinguished between item and node types.

   * [API-CHANGE] To accomodate XEP-0060 better, I've allowed owners to
     have subscription 'none'. This required a change in node_default
     when creating the node. If you create your own nodes without using
     node_default's function, you should probably do this, too.

   * Since subscription options aren't available, assume default
     options of depth 'all' and type 'nodes' for collection nodes and
     'items' for leaf nodes. This does violate the XEP, but is still
     pretty useful for most people and without changing schema I'm not
     sure what else to do.

   * Add support for "pubsub#collection" text-multis in node
     configuration form.

   * Support for notifications of: item publish, item retract, node
     configuration, node purge, node creation, node deletion.

   * Fix a bug when notifying about node deletion, where even owners
     wouldn't get a notification.

   * Normalized a lot of the broadcast code to reduce my typing strain.

   * added mod_pubsub:make_stanza/4 to support SHIM headers.

   * added namespace constants to jlib.hrl for SHIM headers.

MISSING:

   * Subscription options are basically required, but they will require
     a schema change or adding a table.

   * Configuration forms do not distinguish between collection and leaf
     nodes, in violation of the XEP.

   * Subscription depth defaults to all because I can't pass it up from
     get_states/2 in the nodetree module. This also violates the XEP.

   * Localization of configuration form for 'pubsub#collection'

Additional Notes:

	As alluded to above, this is an almost-completely-backwards- 
compatible patch. Everything should continue to work using the new  
support, but new behavior won't be added. The behavior is contingent  
on a nodetree module which does the right thing, and a change to a  
node. The node change is straight -forward, so here it is:

%% Get all the states for the current node and the states for all its
%% parents.
get_states(Host, Node) ->
     Parents = nodetree_dag:find_parents(Host, Node),
     QS = qlc:q([State || State <- mnesia:table(pubsub_state),
                          element(2, State#pubsub_state.stateid) ==  
{Host, Node}]),
     QP = qlc:q([State || State <- mnesia:table(pubsub_state),
                         #pubsub_node{nodeid = {PHost, PNode}} <-  
Parents,
                         element(2, State#pubsub_state.stateid) ==  
{PHost, PNode}]),
     {result, qlc:e(qlc:append(QS, QP))}.


	That relies on the nodetree_dag, which is attached to the ticket.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20081211/64936e18/attachment.htm>


More information about the ejabberd mailing list