mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
Fix pubsub/odbc crash on remote user unsubscribe (EJAB-1483)
This commit is contained in:
parent
b2f98099bb
commit
b83c07251c
@ -733,39 +733,42 @@ in_subscription(_, _, _, _, _, _) ->
|
|||||||
true.
|
true.
|
||||||
|
|
||||||
unsubscribe_user(Entity, Owner) ->
|
unsubscribe_user(Entity, Owner) ->
|
||||||
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
|
||||||
Host = host(element(2, BJID)),
|
|
||||||
spawn(fun () ->
|
spawn(fun () ->
|
||||||
lists:foreach(fun (PType) ->
|
[unsubscribe_user(ServerHost, Entity, Owner) ||
|
||||||
{result, Subs} = node_action(Host, PType,
|
ServerHost <- lists:usort(lists:foldl(
|
||||||
get_entity_subscriptions,
|
fun(UserHost, Acc) ->
|
||||||
[Host, Entity]),
|
case gen_mod:is_loaded(UserHost, mod_pubsub) of
|
||||||
lists:foreach(fun
|
true -> [UserHost|Acc];
|
||||||
({#pubsub_node{options = Options,
|
false -> Acc
|
||||||
owners = O,
|
end
|
||||||
id = Nidx},
|
end, [], [Entity#jid.lserver, Owner#jid.lserver]))]
|
||||||
subscribed, _, JID}) ->
|
|
||||||
case match_option(Options, access_model, presence) of
|
|
||||||
true ->
|
|
||||||
Owners = node_owners_action(Host, PType, Nidx, O),
|
|
||||||
case lists:member(BJID, Owners) of
|
|
||||||
true ->
|
|
||||||
node_action(Host, PType,
|
|
||||||
unsubscribe_node,
|
|
||||||
[Nidx, Entity, JID, all]);
|
|
||||||
false ->
|
|
||||||
{result, ok}
|
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
{result, ok}
|
|
||||||
end;
|
|
||||||
(_) ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
Subs)
|
|
||||||
end,
|
|
||||||
plugins(Host))
|
|
||||||
end).
|
end).
|
||||||
|
unsubscribe_user(Host, Entity, Owner) ->
|
||||||
|
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||||
|
lists:foreach(fun (PType) ->
|
||||||
|
{result, Subs} = node_action(Host, PType,
|
||||||
|
get_entity_subscriptions,
|
||||||
|
[Host, Entity]),
|
||||||
|
lists:foreach(fun
|
||||||
|
({#pubsub_node{options = Options,
|
||||||
|
owners = O,
|
||||||
|
id = Nidx},
|
||||||
|
subscribed, _, JID}) ->
|
||||||
|
Unsubscribe = match_option(Options, access_model, presence)
|
||||||
|
andalso lists:member(BJID, node_owners_action(Host, PType, Nidx, O)),
|
||||||
|
case Unsubscribe of
|
||||||
|
true ->
|
||||||
|
node_action(Host, PType,
|
||||||
|
unsubscribe_node, [Nidx, Entity, JID, all]);
|
||||||
|
false ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
|
(_) ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
|
Subs)
|
||||||
|
end,
|
||||||
|
plugins(Host)).
|
||||||
|
|
||||||
%% -------
|
%% -------
|
||||||
%% user remove hook handling function
|
%% user remove hook handling function
|
||||||
|
Loading…
Reference in New Issue
Block a user