mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-27 14:30:55 +02:00
mod_irc: Make use of MUC password
This commit is contained in:
parent
522eb0fe9d
commit
7623ebd327
@ -206,6 +206,31 @@ code_change(_OldVsn, StateName, StateData, _Extra) ->
|
|||||||
StateData#state{outbuf = StateData#state.outbuf ++ S}
|
StateData#state{outbuf = StateData#state.outbuf ++ S}
|
||||||
end).
|
end).
|
||||||
|
|
||||||
|
get_password_from_presence({xmlelement, "presence", _Attrs, Els}) ->
|
||||||
|
case lists:filter(fun(El) ->
|
||||||
|
case El of
|
||||||
|
{xmlelement, "x", Attrs, _Els} ->
|
||||||
|
case xml:get_attr_s("xmlns", Attrs) of
|
||||||
|
?NS_MUC ->
|
||||||
|
true;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end, Els) of
|
||||||
|
[ElXMUC | _] ->
|
||||||
|
case xml:get_subtag(ElXMUC, "password") of
|
||||||
|
{xmlelement, "password", _, _} = PasswordTag ->
|
||||||
|
{true, xml:get_tag_cdata(PasswordTag)};
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
%% Func: handle_info/3
|
%% Func: handle_info/3
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
%% Returns: {next_state, NextStateName, NextStateData} |
|
||||||
@ -213,7 +238,7 @@ code_change(_OldVsn, StateName, StateData, _Extra) ->
|
|||||||
%% {stop, Reason, NewStateData}
|
%% {stop, Reason, NewStateData}
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
handle_info({route_chan, Channel, Resource,
|
handle_info({route_chan, Channel, Resource,
|
||||||
{xmlelement, "presence", Attrs, _Els}},
|
{xmlelement, "presence", Attrs, _Els} = Presence},
|
||||||
StateName, StateData) ->
|
StateName, StateData) ->
|
||||||
NewStateData =
|
NewStateData =
|
||||||
case xml:get_attr_s("type", Attrs) of
|
case xml:get_attr_s("type", Attrs) of
|
||||||
@ -247,7 +272,12 @@ handle_info({route_chan, Channel, Resource,
|
|||||||
true ->
|
true ->
|
||||||
S1;
|
S1;
|
||||||
_ ->
|
_ ->
|
||||||
S2 = ?SEND(io_lib:format("JOIN #~s\r\n", [Channel])),
|
case get_password_from_presence(Presence) of
|
||||||
|
{true, Password} ->
|
||||||
|
S2 = ?SEND(io_lib:format("JOIN #~s ~s\r\n", [Channel, Password]));
|
||||||
|
_ ->
|
||||||
|
S2 = ?SEND(io_lib:format("JOIN #~s\r\n", [Channel]))
|
||||||
|
end,
|
||||||
S2#state{channels =
|
S2#state{channels =
|
||||||
dict:store(Channel, ?SETS:new(),
|
dict:store(Channel, ?SETS:new(),
|
||||||
S1#state.channels)}
|
S1#state.channels)}
|
||||||
|
Loading…
Reference in New Issue
Block a user