mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
Reorganize the push_item function, and handle version not_found (EJAB-1420)
This commit is contained in:
parent
c611361bbe
commit
b8026d8df7
@ -657,10 +657,18 @@ push_item(User, Server, From, Item)
|
|||||||
%% Item = rosteritem()
|
%% Item = rosteritem()
|
||||||
|
|
||||||
% TODO: don't push to those who didn't load roster
|
% 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),
|
when is_binary(User), is_binary(Server), is_binary(Resource),
|
||||||
?IS_JID(From) ->
|
?IS_JID(From) ->
|
||||||
|
ExtraAttrs = case RosterVersion of
|
||||||
|
not_found -> [];
|
||||||
|
_ -> [?XMLATTR(<<"ver">>, RosterVersion)]
|
||||||
|
end,
|
||||||
Request = #xmlel{ns = ?NS_ROSTER, name = 'query',
|
Request = #xmlel{ns = ?NS_ROSTER, name = 'query',
|
||||||
|
attrs = ExtraAttrs,
|
||||||
children = [item_to_xml(Item)]},
|
children = [item_to_xml(Item)]},
|
||||||
ResIQ = exmpp_iq:set(?NS_JABBER_CLIENT, Request,
|
ResIQ = exmpp_iq:set(?NS_JABBER_CLIENT, Request,
|
||||||
"push" ++ randoms:get_string()),
|
"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
|
%% TODO: don't push to those who didn't load roster
|
||||||
push_item_version(Server, User, From, Item, RosterVersion) ->
|
push_item_version(Server, User, From, Item, RosterVersion) ->
|
||||||
lists:foreach(fun(Resource) ->
|
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)).
|
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
|
%% @spec (Ignored, User, Server) -> Subscription_Lists
|
||||||
%% Ignored = term()
|
%% Ignored = term()
|
||||||
%% User = binary()
|
%% User = binary()
|
||||||
|
Loading…
Reference in New Issue
Block a user