Update add_roster_item and get_roster to ejabberd 13
This commit is contained in:
parent
341c8531be
commit
f7c243ab4f
|
@ -360,7 +360,7 @@ commands() ->
|
||||||
args = [{localuser, binary}, {localserver, binary},
|
args = [{localuser, binary}, {localserver, binary},
|
||||||
{user, binary}, {server, binary},
|
{user, binary}, {server, binary},
|
||||||
{nick, binary}, {group, binary},
|
{nick, binary}, {group, binary},
|
||||||
{subs, string}],
|
{subs, binary}],
|
||||||
result = {res, rescode}},
|
result = {res, rescode}},
|
||||||
%%{"", "subs= none, from, to or both"},
|
%%{"", "subs= none, from, to or both"},
|
||||||
%%{"", "example: add-roster peter localhost mike server.com MiKe Employees both"},
|
%%{"", "example: add-roster peter localhost mike server.com MiKe Employees both"},
|
||||||
|
@ -1064,7 +1064,7 @@ update_vcard_els(Data, ContentList, Els1) ->
|
||||||
%%%
|
%%%
|
||||||
|
|
||||||
add_rosteritem(LocalUser, LocalServer, User, Server, Nick, Group, Subs) ->
|
add_rosteritem(LocalUser, LocalServer, User, Server, Nick, Group, Subs) ->
|
||||||
case add_rosteritem(LocalUser, LocalServer, User, Server, Nick, Group, list_to_atom(Subs), []) of
|
case add_rosteritem(LocalUser, LocalServer, User, Server, Nick, Group, Subs, []) of
|
||||||
{atomic, ok} ->
|
{atomic, ok} ->
|
||||||
push_roster_item(LocalUser, LocalServer, User, Server, {add, Nick, Subs, Group}),
|
push_roster_item(LocalUser, LocalServer, User, Server, {add, Nick, Subs, Group}),
|
||||||
ok;
|
ok;
|
||||||
|
@ -1076,13 +1076,8 @@ add_rosteritem(LU, LS, User, Server, Nick, Group, Subscription, Xattrs) ->
|
||||||
subscribe(LU, LS, User, Server, Nick, Group, Subscription, Xattrs).
|
subscribe(LU, LS, User, Server, Nick, Group, Subscription, Xattrs).
|
||||||
|
|
||||||
subscribe(LU, LS, User, Server, Nick, Group, Subscription, _Xattrs) ->
|
subscribe(LU, LS, User, Server, Nick, Group, Subscription, _Xattrs) ->
|
||||||
SubscriptionS = case is_atom(Subscription) of
|
ItemEl = build_roster_item(User, Server, {add, Nick, Subscription, Group}),
|
||||||
true -> atom_to_list(Subscription);
|
mod_roster:set_items(
|
||||||
false -> Subscription
|
|
||||||
end,
|
|
||||||
ItemEl = build_roster_item(User, Server, {add, Nick, SubscriptionS, Group}),
|
|
||||||
{ok, M} = loaded_module(LS,[mod_roster_odbc,mod_roster]),
|
|
||||||
M:set_items(
|
|
||||||
LU, LS,
|
LU, LS,
|
||||||
{xmlel, <<"query">>,
|
{xmlel, <<"query">>,
|
||||||
[{<<"xmlns">>, <<"jabber:iq:roster">>}],
|
[{<<"xmlns">>, <<"jabber:iq:roster">>}],
|
||||||
|
@ -1099,22 +1094,12 @@ delete_rosteritem(LocalUser, LocalServer, User, Server) ->
|
||||||
|
|
||||||
unsubscribe(LU, LS, User, Server) ->
|
unsubscribe(LU, LS, User, Server) ->
|
||||||
ItemEl = build_roster_item(User, Server, remove),
|
ItemEl = build_roster_item(User, Server, remove),
|
||||||
{ok, M} = loaded_module(LS,[mod_roster_odbc,mod_roster]),
|
mod_roster:set_items(
|
||||||
M:set_items(
|
|
||||||
LU, LS,
|
LU, LS,
|
||||||
{xmlel, <<"query">>,
|
{xmlel, <<"query">>,
|
||||||
[{<<"xmlns">>, <<"jabber:iq:roster">>}],
|
[{<<"xmlns">>, <<"jabber:iq:roster">>}],
|
||||||
[ItemEl]}).
|
[ItemEl]}).
|
||||||
|
|
||||||
loaded_module(Domain,Options) ->
|
|
||||||
LoadedModules = gen_mod:loaded_modules(Domain),
|
|
||||||
case lists:filter(fun(Module) ->
|
|
||||||
lists:member(Module, LoadedModules)
|
|
||||||
end, Options) of
|
|
||||||
[M|_] -> {ok, M};
|
|
||||||
[] -> {error,not_found}
|
|
||||||
end.
|
|
||||||
|
|
||||||
%% -----------------------------
|
%% -----------------------------
|
||||||
%% Get Roster
|
%% Get Roster
|
||||||
%% -----------------------------
|
%% -----------------------------
|
||||||
|
@ -1170,7 +1155,7 @@ subscribe_roster({Name, Server, Group, Nick}, [{Name, Server, _, _} | Roster]) -
|
||||||
subscribe_roster({Name, Server, Group, Nick}, Roster);
|
subscribe_roster({Name, Server, Group, Nick}, Roster);
|
||||||
%% Subscribe Name2 to Name1
|
%% Subscribe Name2 to Name1
|
||||||
subscribe_roster({Name1, Server1, Group1, Nick1}, [{Name2, Server2, Group2, Nick2} | Roster]) ->
|
subscribe_roster({Name1, Server1, Group1, Nick1}, [{Name2, Server2, Group2, Nick2} | Roster]) ->
|
||||||
subscribe(Name1, Server1, Name2, Server2, Nick2, Group2, both, []),
|
subscribe(Name1, Server1, Name2, Server2, Nick2, Group2, <<"both">>, []),
|
||||||
subscribe_roster({Name1, Server1, Group1, Nick1}, Roster).
|
subscribe_roster({Name1, Server1, Group1, Nick1}, Roster).
|
||||||
|
|
||||||
push_alltoall(S, G) ->
|
push_alltoall(S, G) ->
|
||||||
|
@ -1216,24 +1201,23 @@ build_roster_item(U, S, remove) ->
|
||||||
}.
|
}.
|
||||||
|
|
||||||
build_iq_roster_push(Item) ->
|
build_iq_roster_push(Item) ->
|
||||||
{xmlelement, "iq",
|
{xmlel, <<"iq">>,
|
||||||
[{"type", "set"}, {"id", "push"}],
|
[{<<"type">>, <<"set">>}, {<<"id">>, <<"pushaaa">>}],
|
||||||
[{xmlelement, "query",
|
[{xmlel, <<"query">>,
|
||||||
[{"xmlns", ?NS_ROSTER}],
|
[{<<"xmlns">>, ?NS_ROSTER}],
|
||||||
[Item]
|
[Item]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}.
|
}.
|
||||||
|
|
||||||
build_broadcast(U, S, {add, _Nick, Subs, _Group}) ->
|
build_broadcast(U, S, {add, _Nick, Subs, _Group}) ->
|
||||||
build_broadcast(U, S, list_to_atom(Subs));
|
build_broadcast(U, S, list_to_atom(binary_to_list(Subs)));
|
||||||
build_broadcast(U, S, remove) ->
|
build_broadcast(U, S, remove) ->
|
||||||
build_broadcast(U, S, none);
|
build_broadcast(U, S, none);
|
||||||
%% @spec (U::string(), S::string(), Subs::atom()) -> any()
|
%% @spec (U::string(), S::string(), Subs::atom()) -> any()
|
||||||
%% Subs = both | from | to | none
|
%% Subs = both | from | to | none
|
||||||
build_broadcast(U, S, SubsAtom) when is_atom(SubsAtom) ->
|
build_broadcast(U, S, SubsAtom) when is_atom(SubsAtom) ->
|
||||||
{xmlelement, "broadcast", [],
|
{broadcast, {item, {U, S, <<>>}, SubsAtom}
|
||||||
[{item, {U, S, ""}, SubsAtom}]
|
|
||||||
}.
|
}.
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
|
|
Loading…
Reference in New Issue