mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
Corrected mod_blocking hooks return value, activate "Blocked Contacts" privacy list after it is changed (EJAB-1519) (thanks to Karim Gemayel)
This commit is contained in:
parent
33973677f2
commit
64036bc121
@ -67,9 +67,9 @@ process_iq_get(_, From, _To, #iq{ns = ?NS_BLOCKING, payload = SubEl}, _) ->
|
|||||||
true ->
|
true ->
|
||||||
LUser = exmpp_jid:prep_node(From),
|
LUser = exmpp_jid:prep_node(From),
|
||||||
LServer = exmpp_jid:prep_domain(From),
|
LServer = exmpp_jid:prep_domain(From),
|
||||||
process_blocklist_get(LUser, LServer);
|
{stop, process_blocklist_get(LUser, LServer)};
|
||||||
false ->
|
false ->
|
||||||
{error, 'bad-request'}
|
{stop, {error, 'bad-request'}}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
process_iq_get(Acc, _, _, _, _) ->
|
process_iq_get(Acc, _, _, _, _) ->
|
||||||
@ -80,7 +80,7 @@ process_iq_set(_, From, _To, #iq{ns = ?NS_BLOCKING,
|
|||||||
children = SubEls}}) ->
|
children = SubEls}}) ->
|
||||||
LUser = exmpp_jid:prep_node(From),
|
LUser = exmpp_jid:prep_node(From),
|
||||||
LServer = exmpp_jid:prep_domain(From),
|
LServer = exmpp_jid:prep_domain(From),
|
||||||
case {SubElName, exmpp_xml:remove_cdata_from_list(SubEls)} of
|
Res = case {SubElName, exmpp_xml:remove_cdata_from_list(SubEls)} of
|
||||||
{block, []} ->
|
{block, []} ->
|
||||||
{error, 'bad-request'};
|
{error, 'bad-request'};
|
||||||
{block, Els} ->
|
{block, Els} ->
|
||||||
@ -93,7 +93,8 @@ process_iq_set(_, From, _To, #iq{ns = ?NS_BLOCKING,
|
|||||||
process_blocklist_unblock(LUser, LServer, JIDs);
|
process_blocklist_unblock(LUser, LServer, JIDs);
|
||||||
_ ->
|
_ ->
|
||||||
{error, 'bad-request'}
|
{error, 'bad-request'}
|
||||||
end;
|
end,
|
||||||
|
{stop, Res};
|
||||||
|
|
||||||
process_iq_set(Acc, _, _, _) ->
|
process_iq_set(Acc, _, _, _) ->
|
||||||
Acc.
|
Acc.
|
||||||
@ -199,9 +200,10 @@ process_blocklist_block(LUser, LServer, JIDs) ->
|
|||||||
%% [{'=', user_host, {LUser, LServer}},
|
%% [{'=', user_host, {LUser, LServer}},
|
||||||
%% {'=', name, Default}]),
|
%% {'=', name, Default}]),
|
||||||
List = list_data_to_items(Data),
|
List = list_data_to_items(Data),
|
||||||
broadcast_list_update(LUser, LServer, Default, List),
|
UserList = make_userlist(Default, List),
|
||||||
|
broadcast_list_update(LUser, LServer, Default, UserList),
|
||||||
broadcast_blocklist_event(LUser, LServer, {block, JIDs}),
|
broadcast_blocklist_event(LUser, LServer, {block, JIDs}),
|
||||||
{result, []};
|
{result, [], UserList};
|
||||||
Error ->
|
Error ->
|
||||||
?DEBUG("Error ~n~p", [Error]),
|
?DEBUG("Error ~n~p", [Error]),
|
||||||
{error, 'internal-server-error'}
|
{error, 'internal-server-error'}
|
||||||
@ -260,9 +262,10 @@ process_blocklist_unblock_all(LUser, LServer) ->
|
|||||||
{result, []};
|
{result, []};
|
||||||
{atomic, {ok, Default, Data}} ->
|
{atomic, {ok, Default, Data}} ->
|
||||||
List = list_data_to_items(Data),
|
List = list_data_to_items(Data),
|
||||||
broadcast_list_update(LUser, LServer, Default, List),
|
UserList = make_userlist(Default, List),
|
||||||
|
broadcast_list_update(LUser, LServer, Default, UserList),
|
||||||
broadcast_blocklist_event(LUser, LServer, unblock_all),
|
broadcast_blocklist_event(LUser, LServer, unblock_all),
|
||||||
{result, []};
|
{result, [], UserList};
|
||||||
_ ->
|
_ ->
|
||||||
{error, 'internal-server-error'}
|
{error, 'internal-server-error'}
|
||||||
end.
|
end.
|
||||||
@ -305,17 +308,21 @@ process_blocklist_unblock(LUser, LServer, JIDs) ->
|
|||||||
{result, []};
|
{result, []};
|
||||||
{atomic, {ok, Default, Data}} ->
|
{atomic, {ok, Default, Data}} ->
|
||||||
List = list_data_to_items(Data),
|
List = list_data_to_items(Data),
|
||||||
broadcast_list_update(LUser, LServer, Default, List),
|
UserList = make_userlist(Default, List),
|
||||||
|
broadcast_list_update(LUser, LServer, Default, UserList),
|
||||||
broadcast_blocklist_event(LUser, LServer, {unblock, JIDs}),
|
broadcast_blocklist_event(LUser, LServer, {unblock, JIDs}),
|
||||||
{result, []};
|
{result, [], UserList};
|
||||||
_ ->
|
_ ->
|
||||||
{error, 'internal-server-error'}
|
{error, 'internal-server-error'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
broadcast_list_update(LUser, LServer, Name, List) ->
|
make_userlist(Name, List) ->
|
||||||
NeedDb = is_list_needdb(List),
|
NeedDb = is_list_needdb(List),
|
||||||
|
#userlist{name = Name, list = List, needdb = NeedDb}.
|
||||||
|
|
||||||
|
broadcast_list_update(LUser, LServer, Name, UserList) ->
|
||||||
JID = exmpp_jid:make(LUser, LServer),
|
JID = exmpp_jid:make(LUser, LServer),
|
||||||
ListString = lists:flatten(io_lib:format("~p.", [#userlist{name = Name, list = List, needdb = NeedDb}])),
|
ListString = lists:flatten(io_lib:format("~p.", [UserList])),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
JID,
|
JID,
|
||||||
JID,
|
JID,
|
||||||
|
Loading…
Reference in New Issue
Block a user