mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Reorganize the push_item function, and handle version not_found (EJAB-1420)
This commit is contained in:
parent
714dce84db
commit
5a0cfe7e2b
@ -411,10 +411,17 @@ push_item(User, Server, 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(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) ->
|
||||||
|
ExtraAttrs = case RosterVersion of
|
||||||
|
not_found -> [];
|
||||||
|
_ -> [{"ver", RosterVersion}]
|
||||||
|
end,
|
||||||
ResIQ = #iq{type = set, xmlns = ?NS_ROSTER,
|
ResIQ = #iq{type = set, xmlns = ?NS_ROSTER,
|
||||||
id = "push" ++ randoms:get_string(),
|
id = "push" ++ randoms:get_string(),
|
||||||
sub_el = [{xmlelement, "query",
|
sub_el = [{xmlelement, "query",
|
||||||
[{"xmlns", ?NS_ROSTER}],
|
[{"xmlns", ?NS_ROSTER}|ExtraAttrs],
|
||||||
[item_to_xml(Item)]}]},
|
[item_to_xml(Item)]}]},
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
From,
|
From,
|
||||||
@ -425,21 +432,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) ->
|
|
||||||
IQPush = #iq{type = 'set', xmlns = ?NS_ROSTER,
|
|
||||||
id = "push" ++ randoms:get_string(),
|
|
||||||
sub_el = [{xmlelement, "query",
|
|
||||||
[{"xmlns", ?NS_ROSTER},
|
|
||||||
{"ver", RosterVersion}],
|
|
||||||
[item_to_xml(Item)]}]},
|
|
||||||
ejabberd_router:route(
|
|
||||||
From,
|
|
||||||
jlib:make_jid(User, Server, Resource),
|
|
||||||
jlib:iq_to_xml(IQPush)).
|
|
||||||
|
|
||||||
get_subscription_lists(_, User, Server) ->
|
get_subscription_lists(_, User, Server) ->
|
||||||
LUser = jlib:nodeprep(User),
|
LUser = jlib:nodeprep(User),
|
||||||
LServer = jlib:nameprep(Server),
|
LServer = jlib:nameprep(Server),
|
||||||
|
Loading…
Reference in New Issue
Block a user