25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Fix piefxis import of privacy lists (thanks to crosser)(#2412)

This commit is contained in:
Badlop 2018-07-11 12:02:09 +02:00
parent f81b49fe44
commit f40f3a9da7

View File

@ -475,24 +475,41 @@ process_roster(RosterQuery, State = #state{user = U, server = S}) ->
-spec process_privacy(privacy_query(), state()) -> {ok, state()} | {error, _}. -spec process_privacy(privacy_query(), state()) -> {ok, state()} | {error, _}.
process_privacy(#privacy_query{lists = Lists, process_privacy(#privacy_query{lists = Lists,
default = Default, default = Default,
active = Active} = PrivacyQuery, active = Active},
State = #state{user = U, server = S}) -> State = #state{user = U, server = S}) ->
JID = jid:make(U, S), JID = jid:make(U, S),
IQ = #iq{type = set, id = p1_rand:get_string(), if Lists /= undefined ->
from = JID, to = JID, sub_els = [PrivacyQuery]}, process_privacy2(JID, #privacy_query{lists = Lists});
case mod_privacy:process_iq(IQ) of true ->
ok
end,
if Active /= undefined ->
process_privacy2(JID, #privacy_query{active = Active});
true ->
ok
end,
if Default /= undefined ->
process_privacy2(JID, #privacy_query{default = Default});
true ->
ok
end,
{ok, State}.
process_privacy2(JID, PQ) ->
case mod_privacy:process_iq(#iq{type = set, id = p1_rand:get_string(),
from = JID, to = JID,
sub_els = [PQ]}) of
#iq{type = error} = ResIQ -> #iq{type = error} = ResIQ ->
#stanza_error{reason = Reason} = xmpp:get_error(ResIQ), #stanza_error{reason = Reason} = xmpp:get_error(ResIQ),
if Reason == 'item-not-found', Lists == [], if Reason /= 'item-not-found' ->
Active == undefined, Default /= undefined ->
%% Failed to set default list because there is no %% Failed to set default list because there is no
%% list with such name. We shouldn't stop here. %% list with such name. We shouldn't stop here.
{ok, State}; stop("Failed to write default privacy: ~p", [Reason]);
true -> true ->
stop("Failed to write privacy: ~p", [Reason]) ok
end; end;
_ -> _ ->
{ok, State} ok
end. end.
-spec process_private(private(), state()) -> {ok, state()} | {error, _}. -spec process_private(private(), state()) -> {ok, state()} | {error, _}.