diff options
author | Badlop <badlop@process-one.net> | 2011-04-29 22:28:35 +0400 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2011-04-29 22:34:38 +0400 |
commit | b8026d8df7c3b43aaaacf9a4ee6ec7a661d4a6de (patch) | |
tree | cb6c51c2f269a7afaf8dad1df44c38e22b129d72 /src | |
parent | c611361bbe11194d0a6acaa40655918f5d3afe9b (diff) |
Reorganize the push_item function, and handle version not_found (EJAB-1420)
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_roster.erl | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/mod_roster.erl b/src/mod_roster.erl index 6e6a0ca43..02a6bfc71 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -657,10 +657,18 @@ push_item(User, Server, From, Item) %% Item = rosteritem() % TODO: don't push to those who didn't load roster -push_item(User, Server, Resource, From, Item) +push_item(User, Server, Resource, From, Item) -> + push_item(User, Server, Resource, From, Item, not_found). + +push_item(User, Server, Resource, From, Item, RosterVersion) when is_binary(User), is_binary(Server), is_binary(Resource), ?IS_JID(From) -> + ExtraAttrs = case RosterVersion of + not_found -> []; + _ -> [?XMLATTR(<<"ver">>, RosterVersion)] + end, Request = #xmlel{ns = ?NS_ROSTER, name = 'query', + attrs = ExtraAttrs, children = [item_to_xml(Item)]}, ResIQ = exmpp_iq:set(?NS_JABBER_CLIENT, Request, "push" ++ randoms:get_string()), @@ -673,19 +681,9 @@ push_item(User, Server, Resource, From, Item) %% TODO: don't push to those who didn't load roster push_item_version(Server, User, From, Item, RosterVersion) -> lists:foreach(fun(Resource) -> - push_item_version(User, Server, Resource, From, Item, RosterVersion) + push_item(User, Server, Resource, From, Item, RosterVersion) end, ejabberd_sm:get_user_resources(User, Server)). -push_item_version(User, Server, Resource, From, Item, RosterVersion) -> - Request = #xmlel{ns = ?NS_ROSTER, name = 'query', attrs = [?XMLATTR(<<"ver">>, RosterVersion)], - children = [mod_roster:item_to_xml(Item)]}, - ResIQ = exmpp_iq:set(?NS_JABBER_CLIENT, Request, - "push" ++ randoms:get_string()), - ejabberd_router:route( - From, - exmpp_jid:make(User, Server, Resource), - ResIQ). - %% @spec (Ignored, User, Server) -> Subscription_Lists %% Ignored = term() %% User = binary() |