[ejabberd] update the subscription_lists dynamically

Pablo Platt pablo.platt at yahoo.com
Mon Jan 19 14:15:27 MSK 2009

Apparently a similar bug was fixed in mod_shared_roster https://support.process-one.net/browse/EJAB-731
When a new user was added to the shared roster, it wasn't pushed to online users.
I've tried to use the code from mod_shared_roster but it doesn't work so I'm probably missing something.

This is the code I used instead in mod_xmlrpc:

%% add_rosteritem  struct[{localuser, String}, {localserver, String}, 
%%                  {user, String}, {server, String}, 
%%                  {nick, String}, {group, String}, 
%%                  {subs, String}]                                String
handler(_State, {call, add_rosteritem, [{struct, AttrL}]}) ->
    [User, Server, ContactU, ContactS, Nick, GroupName, Subscription] = 
    get_attrs([localuser, localserver, user, server, nick, group, subs], AttrL),
    Node = node(),
    Item = #roster{usj = {User, Server, {ContactU, ContactS, ""}},
    us = {User, Server},
    jid = {ContactU, ContactS, ""},
    name = "",
    subscription = Subscription,
    ask = none,
    groups = [GroupName]},
    From = jlib:make_jid("", Server, ""),
    ejabberd_sm:route(From, jlib:make_jid(User, Server, ""),
              {xmlelement, "broadcast", [],
    push_roster_item(User, Server, ContactU, ContactS, {add, Nick, Subscription, GroupName}),

    {false, {response, ["0"]}};

From: Pablo Platt <pablo.platt at yahoo.com>
To: ejabberd at jabber.ru
Sent: Sunday, January 18, 2009 1:51:09 PM
Subject: [ejabberd] update the subscription_lists dynamically


I'm using add_rosteritem in mod_xmlrpc to sync the roster in my website with ejabberd.
add_rosteritem works well. I can see the roster item on the web admin and the clients 
get a 'push' packet informing them about the new item but they don't get presence updates 
although the subscription is set to 'both'. When client disconnect and reconnect they get presence 
packets from the new items as usual.badlop verified that this happen on 2.0.3 with ejabberdctl 
as well and said that this is the expected behavior.

I want to extend the add_rosteritem function to also update the users subscription_lists if they are online.
In ejabberd_c2s:wait_for_auth there is a part that builds the subscription list:
{Fs, Ts} = ejabberd_hooks:run_fold(
                     {[], []},
                     [U, StateData#state.server]),

I think that when adding a roster item I need to check if the user is online and then add the item to this list.
Is there a function that does that? Can I perhaps simulate a 'subscribed' message using the router?
Am I going in the wrong direction?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20090119/bdc75998/attachment.htm>

More information about the ejabberd mailing list