mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Fix delete item from unregistered user (#2067)
This commit is contained in:
parent
65c85eab03
commit
17e3ed513b
@ -445,21 +445,30 @@ delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||
case Affiliation of
|
||||
owner ->
|
||||
{result, States} = get_states(Nidx),
|
||||
Records = States ++ mnesia:read({pubsub_orphan, Nidx}),
|
||||
lists:foldl(fun
|
||||
(#pubsub_state{items = PI} = S, Res) ->
|
||||
case lists:member(ItemId, PI) of
|
||||
(#pubsub_state{items = RI} = S, Res) ->
|
||||
case lists:member(ItemId, RI) of
|
||||
true ->
|
||||
Nitems = lists:delete(ItemId, PI),
|
||||
NI = lists:delete(ItemId, RI),
|
||||
del_item(Nidx, ItemId),
|
||||
set_state(S#pubsub_state{items = Nitems}),
|
||||
mnesia:write(S#pubsub_state{items = NI}),
|
||||
{result, {default, broadcast}};
|
||||
false ->
|
||||
Res
|
||||
end;
|
||||
(_, Res) ->
|
||||
Res
|
||||
(#pubsub_orphan{items = RI} = S, Res) ->
|
||||
case lists:member(ItemId, RI) of
|
||||
true ->
|
||||
NI = lists:delete(ItemId, RI),
|
||||
del_item(Nidx, ItemId),
|
||||
mnesia:write(S#pubsub_orphan{items = NI}),
|
||||
{result, {default, broadcast}};
|
||||
false ->
|
||||
Res
|
||||
end
|
||||
end,
|
||||
{error, xmpp:err_item_not_found()}, States);
|
||||
{error, xmpp:err_item_not_found()}, Records);
|
||||
_ ->
|
||||
{error, xmpp:err_forbidden()}
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user