25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/mod_muc/mod_muc_room.erl: More accurate invitation errors

(thanks to Magnus Henoch)

SVN Revision: 757
This commit is contained in:
Alexey Shchepin 2007-05-03 04:07:29 +00:00
parent 3acce9763a
commit b9e7fa2ef1
2 changed files with 67 additions and 67 deletions

View File

@ -1,3 +1,8 @@
2007-05-03 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc_room.erl: More accurate invitation errors
(thanks to Magnus Henoch)
2007-04-26 Alexey Shchepin <alexey@sevcom.net>
* src/mod_roster_odbc.erl: Don't deliver roster items in "None +

View File

@ -249,11 +249,10 @@ normal_state({route, From, "",
From, Err),
{next_state, normal_state, StateData};
Type when (Type == "") or (Type == "normal") ->
case check_invitation(From, Els, StateData) of
error ->
ErrText = "It is not allowed to send normal messages to the conference",
case catch check_invitation(From, Els, StateData) of
{error, Error} ->
Err = jlib:make_error_reply(
Packet, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)),
Packet, Error),
ejabberd_router:route(
StateData#state.jid,
From, Err),
@ -2517,18 +2516,33 @@ check_invitation(From, Els, StateData) ->
FAffiliation = get_affiliation(From, StateData),
CanInvite = (StateData#state.config)#config.allow_user_invites
orelse (FAffiliation == admin) orelse (FAffiliation == owner),
case xml:remove_cdata(Els) of
InviteEl = case xml:remove_cdata(Els) of
[{xmlelement, "x", _Attrs1, Els1} = XEl] ->
case xml:get_tag_attr_s("xmlns", XEl) of
?NS_MUC_USER ->
ok;
_ ->
throw({error, ?ERR_BAD_REQUEST})
end,
case xml:remove_cdata(Els1) of
[{xmlelement, "invite", Attrs2, _Els2} = InviteEl] ->
case jlib:string_to_jid(
xml:get_attr_s("to", Attrs2)) of
[{xmlelement, "invite", _Attrs2, _Els2} = InviteEl1] ->
InviteEl1;
_ ->
throw({error, ?ERR_BAD_REQUEST})
end;
_ ->
throw({error, ?ERR_BAD_REQUEST})
end,
JID = case jlib:string_to_jid(
xml:get_tag_attr_s("to", InviteEl)) of
error ->
error;
JID ->
throw({error, ?ERR_JID_MALFORMED});
JID1 ->
JID1
end,
case CanInvite of
false ->
throw({error, ?ERR_NOT_ALLOWED});
true ->
Reason =
xml:get_path_s(
@ -2551,35 +2565,16 @@ check_invitation(From, Els, StateData) ->
Msg =
{xmlelement, "message",
[{"type", "normal"}],
[{xmlelement, "x",
[{"xmlns", ?NS_MUC_USER}],
IEl ++ PasswdEl},
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}], IEl ++ PasswdEl},
{xmlelement, "x",
[{"xmlns",
?NS_XCONFERENCE},
{"jid",
jlib:jid_to_string(
[{"xmlns", ?NS_XCONFERENCE},
{"jid", jlib:jid_to_string(
{StateData#state.room,
StateData#state.host,
""})}],
[{xmlcdata, Reason}]}]},
ejabberd_router:route(
StateData#state.jid,
JID,
Msg),
JID;
_ ->
error
end
end;
_ ->
error
end;
_ ->
error
end;
_ ->
error
ejabberd_router:route(StateData#state.jid, JID, Msg),
JID
end.