mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-14 22:00:16 +02:00
More correct dispatching of normal messages to conference room
is_invitation/1 function returns true if <x> element of message is an invitation
This commit is contained in:
parent
c4f9a050c9
commit
2a41ca0628
|
@ -256,42 +256,48 @@ normal_state({route, From, "",
|
||||||
From, Err),
|
From, Err),
|
||||||
{next_state, normal_state, StateData};
|
{next_state, normal_state, StateData};
|
||||||
Type when (Type == "") or (Type == "normal") ->
|
Type when (Type == "") or (Type == "normal") ->
|
||||||
case catch check_invitation(From, Els, Lang, StateData) of
|
IsInvitation = is_invitation(Els),
|
||||||
{error, Error} ->
|
if
|
||||||
Err = jlib:make_error_reply(
|
IsInvitation ->
|
||||||
Packet, Error),
|
case catch check_invitation(From, Els, Lang, StateData) of
|
||||||
ejabberd_router:route(
|
{error, Error} ->
|
||||||
StateData#state.jid,
|
Err = jlib:make_error_reply(
|
||||||
From, Err),
|
Packet, Error),
|
||||||
{next_state, normal_state, StateData};
|
ejabberd_router:route(
|
||||||
IJID ->
|
StateData#state.jid,
|
||||||
Config = StateData#state.config,
|
From, Err),
|
||||||
case Config#config.members_only of
|
{next_state, normal_state, StateData};
|
||||||
true ->
|
IJID ->
|
||||||
case get_affiliation(IJID, StateData) of
|
Config = StateData#state.config,
|
||||||
none ->
|
case Config#config.members_only of
|
||||||
NSD = set_affiliation(
|
true ->
|
||||||
IJID,
|
case get_affiliation(IJID, StateData) of
|
||||||
member,
|
none ->
|
||||||
StateData),
|
NSD = set_affiliation(
|
||||||
case (NSD#state.config)#config.persistent of
|
IJID,
|
||||||
true ->
|
member,
|
||||||
mod_muc:store_room(
|
StateData),
|
||||||
NSD#state.host,
|
case (NSD#state.config)#config.persistent of
|
||||||
NSD#state.room,
|
true ->
|
||||||
make_opts(NSD));
|
mod_muc:store_room(
|
||||||
|
NSD#state.host,
|
||||||
|
NSD#state.room,
|
||||||
|
make_opts(NSD));
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
|
{next_state, normal_state, NSD};
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
{next_state, normal_state,
|
||||||
end,
|
StateData}
|
||||||
{next_state, normal_state, NSD};
|
end;
|
||||||
_ ->
|
false ->
|
||||||
{next_state, normal_state,
|
{next_state, normal_state, StateData}
|
||||||
StateData}
|
end
|
||||||
end;
|
end;
|
||||||
false ->
|
true ->
|
||||||
{next_state, normal_state, StateData}
|
{next_state, normal_state, StateData}
|
||||||
end
|
end;
|
||||||
end;
|
|
||||||
_ ->
|
_ ->
|
||||||
ErrText = "Improper message type",
|
ErrText = "Improper message type",
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(
|
||||||
|
@ -3623,6 +3629,24 @@ get_mucroom_disco_items(StateData) ->
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% Invitation support
|
% Invitation support
|
||||||
|
|
||||||
|
is_invitation(Els) ->
|
||||||
|
case xml:remove_cdata(Els) of
|
||||||
|
[{xmlelement, "x", _Attrs1, Els1} = XEl] ->
|
||||||
|
case xml:get_tag_attr_s("xmlns", XEl) of
|
||||||
|
?NS_MUC_USER ->
|
||||||
|
case xml:remove_cdata(Els1) of
|
||||||
|
[{xmlelement, "invite", _, _}] ->
|
||||||
|
true;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
|
||||||
check_invitation(From, Els, Lang, StateData) ->
|
check_invitation(From, Els, Lang, StateData) ->
|
||||||
FAffiliation = get_affiliation(From, StateData),
|
FAffiliation = get_affiliation(From, StateData),
|
||||||
CanInvite = (StateData#state.config)#config.allow_user_invites
|
CanInvite = (StateData#state.config)#config.allow_user_invites
|
||||||
|
|
Loading…
Reference in New Issue
Block a user