mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Improve code using new xmpp API
This commit is contained in:
parent
e4a4839880
commit
7a9d2cabc0
@ -24,8 +24,8 @@
|
||||
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.12"}}},
|
||||
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.17"}}},
|
||||
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.10"}}},
|
||||
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.25"}}},
|
||||
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "a893ee1"}},
|
||||
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", "724ec0a"}},
|
||||
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "dbbaed4edfc"}},
|
||||
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.12"}}},
|
||||
{jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}},
|
||||
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.2"}}},
|
||||
|
@ -310,11 +310,8 @@ is_item_not_found({error, #stanza_error{reason = 'item-not-found'}}) -> true;
|
||||
is_item_not_found({error, _}) -> false.
|
||||
|
||||
-spec is_not_subscribed({error, stanza_error()}) -> boolean().
|
||||
is_not_subscribed({error, #stanza_error{sub_els = Els}}) ->
|
||||
%% TODO: make xmpp:get_els function working for any XMPP element
|
||||
%% with sub_els field
|
||||
xmpp:has_subtag(#message{sub_els = Els},
|
||||
#ps_error{type = 'not-subscribed'}).
|
||||
is_not_subscribed({error, StanzaError}) ->
|
||||
xmpp:has_subtag(StanzaError, #ps_error{type = 'not-subscribed'}).
|
||||
|
||||
depends(_Host, _Opts) ->
|
||||
[{mod_pubsub, hard}].
|
||||
|
@ -334,9 +334,8 @@ mk_error(_) ->
|
||||
-spec format_error(db_result()) -> binary().
|
||||
format_error(#db_result{type = invalid}) ->
|
||||
<<"invalid dialback key">>;
|
||||
format_error(#db_result{type = error, sub_els = Els}) ->
|
||||
%% TODO: improve xmpp.erl
|
||||
case xmpp:get_error(#message{sub_els = Els}) of
|
||||
format_error(#db_result{type = error} = Result) ->
|
||||
case xmpp:get_error(Result) of
|
||||
#stanza_error{} = Err ->
|
||||
format_stanza_error(Err);
|
||||
undefined ->
|
||||
|
@ -511,7 +511,7 @@ process_features(StreamFeatures,
|
||||
catch _:undef -> State
|
||||
end,
|
||||
process_stream_established(State1);
|
||||
process_features(#stream_features{sub_els = Els} = StreamFeatures,
|
||||
process_features(StreamFeatures,
|
||||
#{stream_encrypted := Encrypted,
|
||||
mod := Mod, lang := Lang} = State) ->
|
||||
State1 = try Mod:handle_unauthenticated_features(StreamFeatures, State)
|
||||
@ -522,9 +522,7 @@ process_features(#stream_features{sub_els = Els} = StreamFeatures,
|
||||
false ->
|
||||
TLSRequired = is_starttls_required(State1),
|
||||
TLSAvailable = is_starttls_available(State1),
|
||||
%% TODO: improve xmpp.erl
|
||||
Msg = #message{sub_els = Els},
|
||||
case xmpp:get_subtag(Msg, #starttls{}) of
|
||||
case xmpp:get_subtag(StreamFeatures, #starttls{}) of
|
||||
false when TLSRequired and not Encrypted ->
|
||||
Txt = <<"Use of STARTTLS required">>,
|
||||
send_pkt(State1, xmpp:serr_policy_violation(Txt, Lang));
|
||||
@ -545,7 +543,7 @@ process_features(#stream_features{sub_els = Els} = StreamFeatures,
|
||||
case is_disconnected(State2) of
|
||||
true -> State2;
|
||||
false ->
|
||||
case xmpp:get_subtag(Msg, #sasl_mechanisms{}) of
|
||||
case xmpp:get_subtag(StreamFeatures, #sasl_mechanisms{}) of
|
||||
#sasl_mechanisms{list = Mechs} ->
|
||||
process_sasl_mechanisms(Mechs, State2);
|
||||
false ->
|
||||
|
Loading…
Reference in New Issue
Block a user