mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Avoid using maps:get/2 to keep compatibility with OTP 17.5
This commit is contained in:
parent
19bec62eb5
commit
48d8498dbb
@ -176,10 +176,9 @@ open_session(#{user := U, server := S, resource := R,
|
||||
change_shaper(State),
|
||||
Conn = get_conn_type(State),
|
||||
State1 = State#{conn => Conn, resource => R, jid => JID},
|
||||
Prio = try maps:get(pres_last, State) of
|
||||
Prio = case maps:get(pres_last, State, undefined) of
|
||||
undefined -> undefined;
|
||||
Pres -> get_priority_from_presence(Pres)
|
||||
catch _:{badkey, _} ->
|
||||
undefined
|
||||
end,
|
||||
Info = [{ip, IP}, {conn, Conn}, {auth_module, AuthModule}],
|
||||
ejabberd_sm:open_session(SID, U, S, R, Prio, Info),
|
||||
@ -211,10 +210,9 @@ process_info(#{lserver := LServer} = State,
|
||||
State1
|
||||
end;
|
||||
process_info(State, force_update_presence) ->
|
||||
try maps:get(pres_last, State) of
|
||||
case maps:get(pres_last, State, error) of
|
||||
error -> State;
|
||||
Pres -> process_self_presence(State, Pres)
|
||||
catch _:{badkey, _} ->
|
||||
State
|
||||
end;
|
||||
process_info(State, Info) ->
|
||||
?WARNING_MSG("got unexpected info: ~p", [Info]),
|
||||
@ -498,10 +496,11 @@ init([State, Opts]) ->
|
||||
ejabberd_hooks:run_fold(c2s_init, {ok, State1}, [Opts]).
|
||||
|
||||
handle_call(get_presence, From, #{jid := JID} = State) ->
|
||||
Pres = try maps:get(pres_last, State)
|
||||
catch _:{badkey, _} ->
|
||||
Pres = case maps:get(pres_last, State, error) of
|
||||
error ->
|
||||
BareJID = jid:remove_resource(JID),
|
||||
#presence{from = JID, to = BareJID, type = unavailable}
|
||||
#presence{from = JID, to = BareJID, type = unavailable};
|
||||
P -> P
|
||||
end,
|
||||
reply(From, Pres),
|
||||
State;
|
||||
|
@ -339,7 +339,10 @@ queue_new() ->
|
||||
queue_in(Key, Type, Val, {N, Seq, Q}) ->
|
||||
Seq1 = Seq + 1,
|
||||
Time = {Seq1, p1_time_compat:timestamp()},
|
||||
try maps:get(Key, Q) of
|
||||
case maps:get(Key, Q, error) of
|
||||
error ->
|
||||
Q1 = maps:put(Key, [{Type, Time, Val}], Q),
|
||||
{N + 1, Seq1, Q1};
|
||||
TypeVals ->
|
||||
case lists:keymember(Type, 1, TypeVals) of
|
||||
true ->
|
||||
@ -352,9 +355,6 @@ queue_in(Key, Type, Val, {N, Seq, Q}) ->
|
||||
Q1 = maps:put(Key, TypeVals1, Q),
|
||||
{N + 1, Seq1, Q1}
|
||||
end
|
||||
catch _:{badkey, _} ->
|
||||
Q1 = maps:put(Key, [{Type, Time, Val}], Q),
|
||||
{N + 1, Seq1, Q1}
|
||||
end.
|
||||
|
||||
-spec queue_take(term(), csi_queue()) -> {list(), csi_queue()} | error.
|
||||
|
@ -565,10 +565,9 @@ c2s_self_presence({_Pres, #{resend_offline := false}} = Acc) ->
|
||||
Acc;
|
||||
c2s_self_presence({#presence{type = available} = NewPres, State} = Acc) ->
|
||||
NewPrio = get_priority_from_presence(NewPres),
|
||||
LastPrio = try maps:get(pres_last, State) of
|
||||
LastPrio = case maps:get(pres_last, State, error) of
|
||||
error -> -1;
|
||||
LastPres -> get_priority_from_presence(LastPres)
|
||||
catch _:{badkey, _} ->
|
||||
-1
|
||||
end,
|
||||
if LastPrio < 0 andalso NewPrio >= 0 ->
|
||||
route_offline_messages(State);
|
||||
|
@ -40,9 +40,7 @@ authenticate(State) ->
|
||||
-> {ok, binary()} | {error, atom(), binary()}.
|
||||
authenticate(#{xmlns := ?NS_SERVER, sockmod := SockMod,
|
||||
socket := Socket} = State, Authzid) ->
|
||||
Peer = try maps:get(remote_server, State)
|
||||
catch _:{badkey, _} -> Authzid
|
||||
end,
|
||||
Peer = maps:get(remote_server, State, Authzid),
|
||||
case SockMod:get_peer_certificate(Socket) of
|
||||
{ok, Cert} ->
|
||||
case SockMod:get_verify_result(Socket) of
|
||||
|
Loading…
Reference in New Issue
Block a user