mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
purge_offline and get/set affiliation bugfix
This commit is contained in:
parent
d11a715eda
commit
2f899ba76f
@ -1231,7 +1231,8 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
|||||||
iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
|
iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
|
||||||
case exmpp_xml:remove_cdata_from_list(SubEl#xmlel.children) of
|
case exmpp_xml:remove_cdata_from_list(SubEl#xmlel.children) of
|
||||||
[#xmlel{name = Name, attrs = Attrs, children = Els} | Rest] ->
|
[#xmlel{name = Name, attrs = Attrs, children = Els} | Rest] ->
|
||||||
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', false)),
|
%% Fix bug when owner retrieves his affiliations
|
||||||
|
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
||||||
case {IQType, Name} of
|
case {IQType, Name} of
|
||||||
{set, 'create'} ->
|
{set, 'create'} ->
|
||||||
Config = case Rest of
|
Config = case Rest of
|
||||||
@ -2443,8 +2444,9 @@ get_affiliations(Host, Node, JID) ->
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {_, []}} ->
|
%% Fix bug when user retrieves his affiliations
|
||||||
{error, 'item-not-found'};
|
%{result, {_, []}} ->
|
||||||
|
% {error, 'item-not-found'};
|
||||||
{result, {_, Affiliations}} ->
|
{result, {_, Affiliations}} ->
|
||||||
Entities = lists:flatmap(
|
Entities = lists:flatmap(
|
||||||
fun({_, none}) -> [];
|
fun({_, none}) -> [];
|
||||||
@ -2478,7 +2480,7 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
|
|||||||
_:_ -> error
|
_:_ -> error
|
||||||
end,
|
end,
|
||||||
Affiliation = string_to_affiliation(
|
Affiliation = string_to_affiliation(
|
||||||
exmpp_xml:get_attribute_from_list_as_list(Attrs, 'affiliation', false)),
|
exmpp_xml:get_attribute_from_list_as_list(Attrs, 'affiliation', "")),
|
||||||
if
|
if
|
||||||
(JID == error) or
|
(JID == error) or
|
||||||
(Affiliation == false) ->
|
(Affiliation == false) ->
|
||||||
@ -2733,8 +2735,9 @@ get_subscriptions(Host, Node, JID) ->
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {_, []}} ->
|
%% Fix bug when node owner retrieve an empty subscriptions list
|
||||||
{error, 'item-not-found'};
|
% {result, {_, []}} ->
|
||||||
|
% {error, 'item-not-found'};
|
||||||
{result, {_, Subscriptions}} ->
|
{result, {_, Subscriptions}} ->
|
||||||
Entities = lists:flatmap(
|
Entities = lists:flatmap(
|
||||||
fun({_, none}) -> [];
|
fun({_, none}) -> [];
|
||||||
@ -3201,7 +3204,7 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, NodeId, Type, Nod
|
|||||||
ejabberd_router:route(Sender, exmpp_jid:make(U, S, R), StanzaToSend)
|
ejabberd_router:route(Sender, exmpp_jid:make(U, S, R), StanzaToSend)
|
||||||
end, user_resources(U, S));
|
end, user_resources(U, S));
|
||||||
false ->
|
false ->
|
||||||
ejabberd_router:route(Sender, jlib:make_jid(U, S, ""), StanzaToSend)
|
ejabberd_router:route(Sender, exmpp_jid:make(U, S), StanzaToSend)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end, Contacts);
|
end, Contacts);
|
||||||
@ -3862,38 +3865,31 @@ extended_headers(Jids) ->
|
|||||||
|| Jid <- Jids].
|
|| Jid <- Jids].
|
||||||
|
|
||||||
feature_check_packet(allow, _User, Server, Pres, {From, _To, El}, in) ->
|
feature_check_packet(allow, _User, Server, Pres, {From, _To, El}, in) ->
|
||||||
Host = host(Server),
|
Host = list_to_binary(host(Server)),
|
||||||
case exmpp_jid:prep_domain_as_list(From) of
|
case exmpp_jid:prep_domain(From) of
|
||||||
%% If the sender Server equals Host, the message comes from the Pubsub server
|
%% If the sender Server equals Host, the message comes from the Pubsub server
|
||||||
Host ->
|
Host -> allow;
|
||||||
allow;
|
|
||||||
%% Else, the message comes from PEP
|
%% Else, the message comes from PEP
|
||||||
_ ->
|
_ ->
|
||||||
case xml:get_subtag(El, "event") of
|
case exmpp_xml:get_element(El, 'event') of
|
||||||
{xmlelement, _, Attrs, _} = EventEl ->
|
#xmlel{name = 'event', ns = ?NS_PUBSUB_EVENT} = Event ->
|
||||||
case xml:get_attr_s("xmlns", Attrs) of
|
Items = exmpp_xml:get_element(Event, ?NS_PUBSUB_EVENT, 'items'),
|
||||||
?NS_PUBSUB_EVENT ->
|
Feature = exmpp_xml:get_attribute_as_list(Items, "node", ""),
|
||||||
Feature = xml:get_path_s(EventEl, [{elem, "items"}, {attr, "node"}]),
|
case is_feature_supported(Pres, Feature) of
|
||||||
case is_feature_supported(Pres, Feature) of
|
true -> allow;
|
||||||
true ->
|
false -> deny
|
||||||
allow;
|
end;
|
||||||
false ->
|
_ ->
|
||||||
deny
|
allow
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
allow
|
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
allow
|
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
feature_check_packet(Acc, _User, _Server, _Pres, _Packet, _Direction) ->
|
feature_check_packet(Acc, _User, _Server, _Pres, _Packet, _Direction) ->
|
||||||
Acc.
|
Acc.
|
||||||
|
|
||||||
is_feature_supported({xmlelement, "presence", _, Els}, Feature) ->
|
is_feature_supported(#xmlel{name = 'presence', children = Els}, Feature) ->
|
||||||
case mod_caps:read_caps(Els) of
|
case mod_caps:read_caps(Els) of
|
||||||
nothing -> false;
|
nothing -> false;
|
||||||
Caps -> lists:member(Feature ++ "+notify", mod_caps:get_features(Caps))
|
Caps -> lists:member(Feature ++ "+notify", mod_caps:get_features(Caps))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
on_user_offline(_, JID, _) ->
|
on_user_offline(_, JID, _) ->
|
||||||
@ -3904,6 +3900,7 @@ on_user_offline(_, JID, _) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
purge_offline({User, Server, _} = LJID) ->
|
purge_offline({User, Server, _} = LJID) ->
|
||||||
|
JID = exmpp_jid:make(User, Server),
|
||||||
Host = host(Server),
|
Host = host(Server),
|
||||||
Plugins = plugins(Host),
|
Plugins = plugins(Host),
|
||||||
Result = lists:foldl(
|
Result = lists:foldl(
|
||||||
@ -3912,7 +3909,7 @@ purge_offline({User, Server, _} = LJID) ->
|
|||||||
false ->
|
false ->
|
||||||
{{error, extended_error('feature-not-implemented', unsupported, "retrieve-affiliations")}, Acc};
|
{{error, extended_error('feature-not-implemented', unsupported, "retrieve-affiliations")}, Acc};
|
||||||
true ->
|
true ->
|
||||||
{result, Affiliations} = node_action(Host, Type, get_entity_affiliations, [Host, LJID]),
|
{result, Affiliations} = node_action(Host, Type, get_entity_affiliations, [Host, JID]),
|
||||||
{Status, [Affiliations|Acc]}
|
{Status, [Affiliations|Acc]}
|
||||||
end
|
end
|
||||||
end, {ok, []}, Plugins),
|
end, {ok, []}, Plugins),
|
||||||
|
Loading…
Reference in New Issue
Block a user