mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-25 14:24:55 +02:00
Fix problems in process_rosteritems command
This commit is contained in:
parent
392772977f
commit
9b3dda105d
@ -1496,24 +1496,14 @@ process_rosteritems(ActionS, SubsS, AsksS, UsersS, ContactsS) ->
|
|||||||
[S || S <- string:tokens(ContactsS, ":")]
|
[S || S <- string:tokens(ContactsS, ":")]
|
||||||
),
|
),
|
||||||
|
|
||||||
case rosteritem_purge({Action, Subs, Asks, Users, Contacts}) of
|
rosteritem_purge({Action, Subs, Asks, Users, Contacts}).
|
||||||
{atomic, Res} ->
|
|
||||||
Res;
|
|
||||||
{error, Reason} ->
|
|
||||||
io:format("Error purging rosteritems: ~p~n", [Reason]),
|
|
||||||
error;
|
|
||||||
{badrpc, Reason} ->
|
|
||||||
io:format("BadRPC purging rosteritems: ~p~n", [Reason]),
|
|
||||||
error
|
|
||||||
end.
|
|
||||||
|
|
||||||
%% @spec ({Action::atom(), Subs::[atom()], Asks::[atom()], User::string(), Contact::string()}) -> {atomic, ok}
|
%% @spec ({Action::atom(), Subs::[atom()], Asks::[atom()], User::string(), Contact::string()}) -> {atomic, ok}
|
||||||
rosteritem_purge(Options) ->
|
rosteritem_purge(Options) ->
|
||||||
Num_rosteritems = mnesia:table_info(roster, size),
|
Num_rosteritems = mnesia:table_info(roster, size),
|
||||||
io:format("There are ~p roster items in total.~n", [Num_rosteritems]),
|
io:format("There are ~p roster items in total.~n", [Num_rosteritems]),
|
||||||
Key = mnesia:dirty_first(roster),
|
Key = mnesia:dirty_first(roster),
|
||||||
Res = rip(Key, Options, {0, Num_rosteritems, 0, 0}, []),
|
rip(Key, Options, {0, Num_rosteritems, 0, 0}, []).
|
||||||
{atomic, Res}.
|
|
||||||
|
|
||||||
rip('$end_of_table', _Options, Counters, Res) ->
|
rip('$end_of_table', _Options, Counters, Res) ->
|
||||||
print_progress_line(Counters),
|
print_progress_line(Counters),
|
||||||
@ -1535,8 +1525,8 @@ rip(Key, Options, {Pr, NT, NV, ND}, Res) ->
|
|||||||
apply_action(list, Key) ->
|
apply_action(list, Key) ->
|
||||||
{User, Server, JID} = Key,
|
{User, Server, JID} = Key,
|
||||||
{RUser, RServer, _} = JID,
|
{RUser, RServer, _} = JID,
|
||||||
Jid1string = User ++ "@" ++ Server,
|
Jid1string = <<User/binary, "@", Server/binary>>,
|
||||||
Jid2string = RUser ++ "@" ++ RServer,
|
Jid2string = <<RUser/binary, "@", RServer/binary>>,
|
||||||
io:format("Matches: ~s ~s~n", [Jid1string, Jid2string]),
|
io:format("Matches: ~s ~s~n", [Jid1string, Jid2string]),
|
||||||
{Jid1string, Jid2string};
|
{Jid1string, Jid2string};
|
||||||
apply_action(delete, Key) ->
|
apply_action(delete, Key) ->
|
||||||
@ -1544,6 +1534,8 @@ apply_action(delete, Key) ->
|
|||||||
mnesia:dirty_delete(roster, Key),
|
mnesia:dirty_delete(roster, Key),
|
||||||
R.
|
R.
|
||||||
|
|
||||||
|
print_progress_line({Pr, 0, NV, ND}) ->
|
||||||
|
ok;
|
||||||
print_progress_line({Pr, NT, NV, ND}) ->
|
print_progress_line({Pr, NT, NV, ND}) ->
|
||||||
Pr2 = trunc((NV/NT)*100),
|
Pr2 = trunc((NV/NT)*100),
|
||||||
case Pr == Pr2 of
|
case Pr == Pr2 of
|
||||||
@ -1571,14 +1563,14 @@ decide_rip_jid({UName, UServer, _UResource}, Match_list) ->
|
|||||||
decide_rip_jid({UName, UServer}, Match_list) ->
|
decide_rip_jid({UName, UServer}, Match_list) ->
|
||||||
lists:any(
|
lists:any(
|
||||||
fun(Match_string) ->
|
fun(Match_string) ->
|
||||||
MJID = jlib:string_to_jid(Match_string),
|
MJID = jlib:string_to_jid(list_to_binary(Match_string)),
|
||||||
MName = MJID#jid.luser,
|
MName = MJID#jid.luser,
|
||||||
MServer = MJID#jid.lserver,
|
MServer = MJID#jid.lserver,
|
||||||
Is_server = is_glob_match(UServer, MServer),
|
Is_server = is_glob_match(UServer, MServer),
|
||||||
case MName of
|
case MName of
|
||||||
[] when UName == [] ->
|
<<>> when UName == <<>> ->
|
||||||
Is_server;
|
Is_server;
|
||||||
[] ->
|
<<>> ->
|
||||||
false;
|
false;
|
||||||
_ ->
|
_ ->
|
||||||
Is_server
|
Is_server
|
||||||
|
Loading…
Reference in New Issue
Block a user