mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
fixes some badmatches and calls to undefined functions (part of EJAB-1260)
This commit is contained in:
parent
526912756b
commit
ead2655a62
@ -348,7 +348,7 @@ get_last_info(User, Server) ->
|
||||
case get_mod_last_enabled(Server) of
|
||||
mod_last -> mod_last:get_last_info(User, Server);
|
||||
mod_last_odbc -> mod_last_odbc:get_last_info(User, Server);
|
||||
mod_mod_last -> mod_last_required
|
||||
no_mod_last -> mod_last_required
|
||||
end.
|
||||
|
||||
%% @spec (Server) -> mod_last | mod_last_odbc | no_mod_last
|
||||
|
@ -652,7 +652,7 @@ iq_disco_items(Host, From, Lang, Rsm) ->
|
||||
attrs = [
|
||||
#xmlattr{
|
||||
name = 'jid',
|
||||
value = jlib:jid_to_string({Name, Host, ""})
|
||||
value = exmpp_jid:to_binary(exmpp_jid:make(Name, Host))
|
||||
},
|
||||
#xmlattr{
|
||||
name = 'name',
|
||||
|
@ -439,7 +439,7 @@ normal_state({route, From, ToNick,
|
||||
is_user_online(From, StateData)} of
|
||||
{true, true} ->
|
||||
case Type of
|
||||
"groupchat" ->
|
||||
'groupchat' ->
|
||||
ErrText = "It is not allowed to send private "
|
||||
"messages of type \"groupchat\"",
|
||||
Err = exmpp_stanza:reply_with_error(Packet,
|
||||
@ -1849,7 +1849,7 @@ count_maxstanzas_shift(MaxStanzas, HistoryList) ->
|
||||
end.
|
||||
|
||||
count_maxchars_shift(Nick, MaxSize, HistoryList) ->
|
||||
NLen = string:len(Nick) + 1,
|
||||
NLen = size(Nick) + 1,
|
||||
Sizes = lists:map(
|
||||
fun({_Nick, _Packet, _HaveSubject, _TimeStamp, Size}) ->
|
||||
Size + NLen
|
||||
@ -2762,7 +2762,7 @@ send_kickban_presence1(UJID, Reason, Code, StateData) ->
|
||||
ItemAttrs = [?XMLATTR('affiliation', SAffiliation),
|
||||
?XMLATTR('role', <<"none">>)],
|
||||
ItemEls = case Reason of
|
||||
<<>> ->
|
||||
"" ->
|
||||
[];
|
||||
_ ->
|
||||
[#xmlel{name = 'reason',
|
||||
|
@ -602,7 +602,7 @@ check_packet(_, User, Server,
|
||||
LJID = jlib:short_prepd_jid(To),
|
||||
{Subscription, Groups} =
|
||||
case NeedDb of
|
||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, exmpp_stringprep:nameprep(Server), {none, []}, [User, Server, LJID]);
|
||||
false -> {[], []}
|
||||
end,
|
||||
check_packet_aux(List, presence_out,
|
||||
|
@ -164,7 +164,7 @@ process_iq(InitiatorJID, #iq{type = set, payload = SubEl, ns = ?NS_BYTESTREAMS}
|
||||
allow ->
|
||||
ActivateEl = exmpp_xml:get_path(SubEl, [{element, 'activate'}]),
|
||||
SID = exmpp_xml:get_attribute_as_list(SubEl, 'sid', ""),
|
||||
case catch exmpp_jid:parse(exmpp_xml:get_cdata_as_string(ActivateEl)) of
|
||||
case catch exmpp_jid:parse(exmpp_xml:get_cdata_as_list(ActivateEl)) of
|
||||
TargetJID when ?IS_JID(TargetJID), SID /= "",
|
||||
length(SID) =< 128, TargetJID /= InitiatorJID ->
|
||||
Target = exmpp_jid:prep_to_list(TargetJID),
|
||||
|
@ -1500,7 +1500,7 @@ get_pending_nodes(Host, Owner, Plugins) ->
|
||||
%% subscriptions on Host and Node.</p>
|
||||
send_pending_auth_events(Host, Node, Owner) ->
|
||||
?DEBUG("Sending pending auth events for ~s on ~s:~s",
|
||||
[exmpp_jid:jid_to_string(Owner), Host, node_to_string(Node)]),
|
||||
[exmpp_jid:to_list(Owner), Host, node_to_string(Node)]),
|
||||
Action =
|
||||
fun(#pubsub_node{id = NodeID, type = Type}) ->
|
||||
case lists:member("get-pending", features(Type)) of
|
||||
@ -2727,12 +2727,12 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
|
||||
case Node of
|
||||
<<>> ->
|
||||
[#xmlel{ns = ?NS_PUBSUB, name='subscription',
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)),
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
|
||||
?XMLATTR('subid', SubID),
|
||||
?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}];
|
||||
SubsNode ->
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription',
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)),
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
|
||||
?XMLATTR('subid', SubID),
|
||||
?XMLATTR('subscription', subscription_to_string(Subscription))]}];
|
||||
_ ->
|
||||
@ -3013,7 +3013,7 @@ state_can_deliver({U, S, R}, SubOptions) ->
|
||||
|
||||
get_resource_state({U, S, R}, ShowValues, JIDs) ->
|
||||
%% Get user session PID
|
||||
case ejabberd_sm:get_session_pid(U, S, R) of
|
||||
case ejabberd_sm:get_session_pid(exmpp_jid:make(U, S, R)) of
|
||||
%% If no PID, item can be delivered
|
||||
none -> lists:append([{U, S, R}], JIDs);
|
||||
%% If PID ...
|
||||
|
@ -1315,7 +1315,7 @@ get_pending_nodes(Host, Owner, Plugins) ->
|
||||
%% subscriptions on Host and Node.</p>
|
||||
send_pending_auth_events(Host, Node, Owner) ->
|
||||
?DEBUG("Sending pending auth events for ~s on ~s:~s",
|
||||
[exmpp_jid:jid_to_string(Owner), Host, node_to_string(Node)]),
|
||||
[exmpp_jid:to_list(Owner), Host, node_to_string(Node)]),
|
||||
Action =
|
||||
fun(#pubsub_node{id = NodeID, type = Type}) ->
|
||||
case lists:member("get-pending", features(Type)) of
|
||||
@ -2543,12 +2543,12 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
|
||||
case Node of
|
||||
<<>> ->
|
||||
[#xmlel{ns = ?NS_PUBSUB, name='subscription',
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)),
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
|
||||
?XMLATTR('subid', SubID),
|
||||
?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}];
|
||||
SubsNode ->
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription',
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)),
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
|
||||
?XMLATTR('subid', SubID),
|
||||
?XMLATTR('subscription', subscription_to_string(Subscription))]}];
|
||||
_ ->
|
||||
@ -2829,7 +2829,7 @@ state_can_deliver({U, S, R}, SubOptions) ->
|
||||
|
||||
get_resource_state({U, S, R}, ShowValues, JIDs) ->
|
||||
%% Get user session PID
|
||||
case ejabberd_sm:get_session_pid(U, S, R) of
|
||||
case ejabberd_sm:get_session_pid(exmpp_jid:make(U, S, R)) of
|
||||
%% If no PID, item can be delivered
|
||||
none -> lists:append([{U, S, R}], JIDs);
|
||||
%% If PID ...
|
||||
|
@ -1161,7 +1161,9 @@ set_item(Item) ->
|
||||
{M, JID} = Item#pubsub_item.modification,
|
||||
P = encode_jid(JID),
|
||||
Payload = Item#pubsub_item.payload,
|
||||
XML = ?PUBSUB:escape(lists:flatten(lists:map(fun(X) -> xml:element_to_string(X) end, Payload))),
|
||||
XML = ?PUBSUB:escape(lists:flatten(
|
||||
lists:map(fun(X) -> exmpp_xml:document_to_list(X) end,
|
||||
Payload))),
|
||||
S = fun({T1, T2, T3}) ->
|
||||
lists:flatten([i2l(T1, 6), ":", i2l(T2, 6), ":", i2l(T3, 6)])
|
||||
end,
|
||||
@ -1293,7 +1295,7 @@ update_subscription(NodeId, JID, Subscription) ->
|
||||
"values('", NodeId, "', '", J, "', 'n', '", S, "');"])
|
||||
end.
|
||||
|
||||
decode_jid(SJID) -> jlib:short_prepd_jid(jlib:string_to_jid(SJID)). %% TODO rewrite using exmpp
|
||||
decode_jid(SJID) -> jlib:short_prepd_jid(exmpp_jid:parse(SJID)). %% TODO rewrite using exmpp
|
||||
|
||||
decode_node(N) -> ?PUBSUB:string_to_node(N).
|
||||
|
||||
@ -1315,7 +1317,7 @@ decode_subscriptions(Subscriptions) ->
|
||||
end
|
||||
end, [], string:tokens(Subscriptions, ",")).
|
||||
|
||||
encode_jid(JID) -> ?PUBSUB:escape(jlib:jid_to_string(JID)). %% TODO rewrite using exmpp
|
||||
encode_jid(JID) -> ?PUBSUB:escape(exmpp_jid:to_list(JID)). %% TODO rewrite using exmpp
|
||||
|
||||
encode_affiliation(owner) -> "o";
|
||||
encode_affiliation(publisher) -> "p";
|
||||
|
@ -218,7 +218,7 @@ get_entity_subscriptions(_Host, Owner) ->
|
||||
{selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} ->
|
||||
lists:map(fun({H, N, T, I, J, S}) ->
|
||||
O = node_flat_odbc:decode_jid(H),
|
||||
Node = nodetree_odbc:raw_to_node(O, {N, "", T, I}),
|
||||
Node = nodetree_tree_odbc:raw_to_node(O, {N, "", T, I}),
|
||||
{Node, node_flat_odbc:decode_subscription(S), node_flat_odbc:decode_jid(J)}
|
||||
end, RItems);
|
||||
_ ->
|
||||
@ -251,7 +251,7 @@ get_entity_subscriptions_for_send_last(_Host, Owner) ->
|
||||
{selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} ->
|
||||
lists:map(fun({H, N, T, I, J, S}) ->
|
||||
O = node_flat_odbc:decode_jid(H),
|
||||
Node = nodetree_odbc:raw_to_node(O, {N, "", T, I}),
|
||||
Node = nodetree_tree_odbc:raw_to_node(O, {N, "", T, I}),
|
||||
{Node, node_flat_odbc:decode_subscription(S), node_flat_odbc:decode_jid(J)}
|
||||
end, RItems);
|
||||
_ ->
|
||||
|
@ -238,7 +238,7 @@ type_and_options(Type, _Lang) ->
|
||||
tr_xfield_options({Value, Label}, Lang) ->
|
||||
#xmlel{ns = ?NS_DATA_FORMS,
|
||||
name = 'option',
|
||||
attrs = [?XMLATTR('label', transalte:translate(Lang, Label))],
|
||||
attrs = [?XMLATTR('label', translate:translate(Lang, Label))],
|
||||
children = [#xmlel{ns = ?NS_DATA_FORMS,
|
||||
name = 'value',
|
||||
children = [?XMLCDATA(Value)]}]}.
|
||||
|
@ -773,7 +773,7 @@ remove_user(User, Server) when is_binary(User), is_binary(Server) ->
|
||||
%% Both or To, send a "unsubscribe" presence stanza.
|
||||
send_unsubscription_to_rosteritems(LUser, LServer) ->
|
||||
RosterItems = get_user_roster([], {LUser, LServer}),
|
||||
From = jlib:make_jid({LUser, LServer, ""}),
|
||||
From = exmpp_jid:make(LUser, LServer),
|
||||
lists:foreach(fun(RosterItem) ->
|
||||
send_unsubscribing_presence(From, RosterItem)
|
||||
end,
|
||||
|
Loading…
Reference in New Issue
Block a user