Fix add_rosteritem, delete_rosteritem, and get_roster

This commit is contained in:
Sonny Scroggin 2014-03-25 11:15:53 -05:00 committed by Badlop
parent ffea2bf350
commit 14a3662ca4
1 changed files with 19 additions and 20 deletions

View File

@ -357,9 +357,9 @@ commands() ->
#ejabberd_commands{name = add_rosteritem, tags = [roster], #ejabberd_commands{name = add_rosteritem, tags = [roster],
desc = "Add an item to a user's roster (supports ODBC)", desc = "Add an item to a user's roster (supports ODBC)",
module = ?MODULE, function = add_rosteritem, module = ?MODULE, function = add_rosteritem,
args = [{localuser, string}, {localserver, string}, args = [{localuser, binary}, {localserver, binary},
{user, string}, {server, string}, {user, binary}, {server, binary},
{nick, string}, {group, string}, {nick, binary}, {group, binary},
{subs, string}], {subs, string}],
result = {res, rescode}}, result = {res, rescode}},
%%{"", "subs= none, from, to or both"}, %%{"", "subs= none, from, to or both"},
@ -368,8 +368,8 @@ commands() ->
#ejabberd_commands{name = delete_rosteritem, tags = [roster], #ejabberd_commands{name = delete_rosteritem, tags = [roster],
desc = "Delete an item from a user's roster (supports ODBC)", desc = "Delete an item from a user's roster (supports ODBC)",
module = ?MODULE, function = delete_rosteritem, module = ?MODULE, function = delete_rosteritem,
args = [{localuser, string}, {localserver, string}, args = [{localuser, binary}, {localserver, binary},
{user, string}, {server, string}], {user, binary}, {server, binary}],
result = {res, rescode}}, result = {res, rescode}},
#ejabberd_commands{name = process_rosteritems, tags = [roster], #ejabberd_commands{name = process_rosteritems, tags = [roster],
desc = "List or delete rosteritems that match filtering options", desc = "List or delete rosteritems that match filtering options",
@ -413,7 +413,7 @@ commands() ->
#ejabberd_commands{name = get_roster, tags = [roster], #ejabberd_commands{name = get_roster, tags = [roster],
desc = "Get roster of a local user", desc = "Get roster of a local user",
module = ?MODULE, function = get_roster, module = ?MODULE, function = get_roster,
args = [{user, string}, {host, string}], args = [{user, binary}, {host, binary}],
result = {contacts, {list, {contact, {tuple, [ result = {contacts, {list, {contact, {tuple, [
{jid, string}, {jid, string},
{nick, string}, {nick, string},
@ -1084,8 +1084,8 @@ subscribe(LU, LS, User, Server, Nick, Group, Subscription, _Xattrs) ->
{ok, M} = loaded_module(LS,[mod_roster_odbc,mod_roster]), {ok, M} = loaded_module(LS,[mod_roster_odbc,mod_roster]),
M:set_items( M:set_items(
LU, LS, LU, LS,
{xmlelement,"query", {xmlel, <<"query">>,
[{"xmlns","jabber:iq:roster"}], [{<<"xmlns">>, <<"jabber:iq:roster">>}],
[ItemEl]}). [ItemEl]}).
delete_rosteritem(LocalUser, LocalServer, User, Server) -> delete_rosteritem(LocalUser, LocalServer, User, Server) ->
@ -1102,8 +1102,8 @@ unsubscribe(LU, LS, User, Server) ->
{ok, M} = loaded_module(LS,[mod_roster_odbc,mod_roster]), {ok, M} = loaded_module(LS,[mod_roster_odbc,mod_roster]),
M:set_items( M:set_items(
LU, LS, LU, LS,
{xmlelement,"query", {xmlel, <<"query">>,
[{"xmlns","jabber:iq:roster"}], [{<<"xmlns">>, <<"jabber:iq:roster">>}],
[ItemEl]}). [ItemEl]}).
loaded_module(Domain,Options) -> loaded_module(Domain,Options) ->
@ -1136,8 +1136,7 @@ make_roster_xmlrpc(Roster) ->
[] -> [""]; [] -> [""];
Gs -> Gs Gs -> Gs
end, end,
ItemsX = [{JIDS, Nick, Subs, Ask, Group} ItemsX = [{JIDS, Nick, Subs, Ask, Group} || Group <- Groups],
|| Group <- Groups],
ItemsX ++ Res ItemsX ++ Res
end, end,
[], [],
@ -1203,16 +1202,16 @@ push_roster_item(LU, LS, R, U, S, Action) ->
ejabberd_router:route(LJID, LJID, ResIQ). ejabberd_router:route(LJID, LJID, ResIQ).
build_roster_item(U, S, {add, Nick, Subs, Group}) -> build_roster_item(U, S, {add, Nick, Subs, Group}) ->
{xmlelement, "item", {xmlel, <<"item">>,
[{"jid", jlib:jid_to_string(jlib:make_jid(U, S, ""))}, [{<<"jid">>, jlib:jid_to_string(jlib:make_jid(U, S, <<>>))},
{"name", Nick}, {<<"name">>, Nick},
{"subscription", Subs}], {<<"subscription">>, Subs}],
[{xmlelement, "group", [], [{xmlcdata, Group}]}] [{xmlel, <<"group">>, [], [{xmlcdata, Group}]}]
}; };
build_roster_item(U, S, remove) -> build_roster_item(U, S, remove) ->
{xmlelement, "item", {xmlel, <<"item">>,
[{"jid", jlib:jid_to_string(jlib:make_jid(U, S, ""))}, [{<<"jid">>, jlib:jid_to_string(jlib:make_jid(U, S, <<>>))},
{"subscription", "remove"}], {<<"subscription">>, <<"remove">>}],
[] []
}. }.