Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2018-07-11 13:02:09 +0300
committerBadlop <badlop@process-one.net>2018-07-11 13:56:57 +0300
commitf40f3a9da77ad2d69103019ef532a72191fd3d27 (patch)
treed5a15cbf71bc2074b50cca5dfd2a29efdfc50898
parentf81b49fe44ee03dbdd2ab314aa4e32464825946e (diff)
Fix piefxis import of privacy lists (thanks to crosser)(#2412)
-rw-r--r--src/ejabberd_piefxis.erl47
1 files changed, 32 insertions, 15 deletions
diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl
index 591b8dde0..541fcad8b 100644
--- a/src/ejabberd_piefxis.erl
+++ b/src/ejabberd_piefxis.erl
@@ -475,25 +475,42 @@ process_roster(RosterQuery, State = #state{user = U, server = S}) ->
-spec process_privacy(privacy_query(), state()) -> {ok, state()} | {error, _}.
process_privacy(#privacy_query{lists = Lists,
default = Default,
- active = Active} = PrivacyQuery,
+ active = Active},
State = #state{user = U, server = S}) ->
JID = jid:make(U, S),
- IQ = #iq{type = set, id = p1_rand:get_string(),
- from = JID, to = JID, sub_els = [PrivacyQuery]},
- case mod_privacy:process_iq(IQ) of
- #iq{type = error} = ResIQ ->
- #stanza_error{reason = Reason} = xmpp:get_error(ResIQ),
- if Reason == 'item-not-found', Lists == [],
- Active == undefined, Default /= undefined ->
+ if Lists /= undefined ->
+ process_privacy2(JID, #privacy_query{lists = Lists});
+ 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 ->
+ #stanza_error{reason = Reason} = xmpp:get_error(ResIQ),
+ if Reason /= 'item-not-found' ->
%% Failed to set default list because there is no
%% list with such name. We shouldn't stop here.
- {ok, State};
- true ->
- stop("Failed to write privacy: ~p", [Reason])
- end;
- _ ->
- {ok, State}
- end.
+ stop("Failed to write default privacy: ~p", [Reason]);
+ true ->
+ ok
+ end;
+ _ ->
+ ok
+ end.
-spec process_private(private(), state()) -> {ok, state()} | {error, _}.
process_private(Private, State = #state{user = U, server = S}) ->