25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Fix PEP issues (#1636)

This commit is contained in:
Christophe Romain 2017-03-27 16:24:24 +02:00
parent e30d41e5f0
commit 5b6d042de2
2 changed files with 15 additions and 26 deletions

View File

@ -92,12 +92,12 @@ get_features(Host, #caps{node = Node, version = Version,
-spec list_features(ejabberd_c2s:state()) -> [{ljid(), caps()}]. -spec list_features(ejabberd_c2s:state()) -> [{ljid(), caps()}].
list_features(C2SState) -> list_features(C2SState) ->
Rs = maps:get(caps_features, C2SState, gb_trees:empty()), Rs = maps:get(caps_resources, C2SState, gb_trees:empty()),
gb_trees:to_list(Rs). gb_trees:to_list(Rs).
-spec get_user_caps(jid(), ejabberd_c2s:state()) -> {ok, caps()} | error. -spec get_user_caps(jid(), ejabberd_c2s:state()) -> {ok, caps()} | error.
get_user_caps(JID, C2SState) -> get_user_caps(JID, C2SState) ->
Rs = maps:get(caps_features, C2SState, gb_trees:empty()), Rs = maps:get(caps_resources, C2SState, gb_trees:empty()),
LJID = jid:tolower(JID), LJID = jid:tolower(JID),
case gb_trees:lookup(LJID, Rs) of case gb_trees:lookup(LJID, Rs) of
{value, Caps} -> {value, Caps} ->
@ -209,7 +209,7 @@ c2s_presence_in(C2SState,
Delete = (Type == unavailable) or (Type == error), Delete = (Type == unavailable) or (Type == error),
if Insert or Delete -> if Insert or Delete ->
LFrom = jid:tolower(From), LFrom = jid:tolower(From),
Rs = maps:get(caps_resources, C2SState, gb_trees:empty()), Rs = maps:get(caps_resources, C2SState, gb_trees:empty()),
Caps = read_caps(Presence), Caps = read_caps(Presence),
NewRs = case Caps of NewRs = case Caps of
nothing when Insert == true -> Rs; nothing when Insert == true -> Rs;

View File

@ -1215,7 +1215,7 @@ iq_pubsub(Host, Access, #iq{from = From, type = IQType, lang = Lang,
create_node(Host, ServerHost, Node, From, Type, Access, Config) create_node(Host, ServerHost, Node, From, Type, Access, Config)
end; end;
{set, #pubsub{publish = #ps_publish{node = Node, items = Items}, {set, #pubsub{publish = #ps_publish{node = Node, items = Items},
publish_options = XData, _ = undefined}} -> publish_options = XData, configure = _, _ = undefined}} ->
ServerHost = serverhost(Host), ServerHost = serverhost(Host),
case Items of case Items of
[#ps_item{id = ItemId, xml_els = Payload}] -> [#ps_item{id = ItemId, xml_els = Payload}] ->
@ -2215,23 +2215,12 @@ send_items(Host, Node, _Nidx, _Type, Options, LJID, _) ->
Stanza = items_event_stanza(Node, Options, []), Stanza = items_event_stanza(Node, Options, []),
dispatch_items(Host, LJID, Node, Stanza). dispatch_items(Host, LJID, Node, Stanza).
dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, dispatch_items({FromU, FromS, FromR}, To, Node, Stanza) ->
Node, Stanza) -> SenderResource = user_resource(FromU, FromS, FromR),
C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of ejabberd_sm:route(jid:make(FromU, FromS, SenderResource),
ToPid when is_pid(ToPid) -> ToPid; {send_filtered, {pep_message, <<((Node))/binary, "+notify">>},
_ -> jid:make(FromU, FromS), jid:make(To),
R = user_resource(FromU, FromS, FromR), Stanza});
case ejabberd_sm:get_session_pid(FromU, FromS, R) of
FromPid when is_pid(FromPid) -> FromPid;
_ -> undefined
end
end,
if C2SPid == undefined -> ok;
true ->
C2SPid ! {send_filtered, {pep_message, <<Node/binary, "+notify">>},
service_jid(From), jid:make(To),
Stanza}
end;
dispatch_items(From, To, _Node, Stanza) -> dispatch_items(From, To, _Node, Stanza) ->
ejabberd_router:route( ejabberd_router:route(
xmpp:set_from_to(Stanza, service_jid(From), jid:make(To))). xmpp:set_from_to(Stanza, service_jid(From), jid:make(To))).
@ -3016,11 +3005,11 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, Nidx, Type, NodeO
broadcast_stanza({LUser, LServer, <<>>}, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM), broadcast_stanza({LUser, LServer, <<>>}, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM),
%% Handles implicit presence subscriptions %% Handles implicit presence subscriptions
SenderResource = user_resource(LUser, LServer, LResource), SenderResource = user_resource(LUser, LServer, LResource),
NotificationType = get_option(NodeOptions, notification_type, headline), NotificationType = get_option(NodeOptions, notification_type, headline),
Stanza = add_message_type(BaseStanza, NotificationType), Stanza = add_message_type(BaseStanza, NotificationType),
%% set the from address on the notification to the bare JID of the account owner %% set the from address on the notification to the bare JID of the account owner
%% Also, add "replyto" if entity has presence subscription to the account owner %% Also, add "replyto" if entity has presence subscription to the account owner
%% See XEP-0163 1.1 section 4.3.1 %% See XEP-0163 1.1 section 4.3.1
ejabberd_sm:route(jid:make(LUser, LServer, SenderResource), ejabberd_sm:route(jid:make(LUser, LServer, SenderResource),
{pep_message, <<((Node))/binary, "+notify">>, {pep_message, <<((Node))/binary, "+notify">>,
jid:make(LUser, LServer), jid:make(LUser, LServer),