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:
parent
3acce9763a
commit
b9e7fa2ef1
@ -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>
|
2007-04-26 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/mod_roster_odbc.erl: Don't deliver roster items in "None +
|
* src/mod_roster_odbc.erl: Don't deliver roster items in "None +
|
||||||
|
@ -249,11 +249,10 @@ 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 check_invitation(From, Els, StateData) of
|
case catch check_invitation(From, Els, StateData) of
|
||||||
error ->
|
{error, Error} ->
|
||||||
ErrText = "It is not allowed to send normal messages to the conference",
|
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(
|
||||||
Packet, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)),
|
Packet, Error),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
StateData#state.jid,
|
StateData#state.jid,
|
||||||
From, Err),
|
From, Err),
|
||||||
@ -2517,69 +2516,65 @@ check_invitation(From, Els, 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
|
||||||
orelse (FAffiliation == admin) orelse (FAffiliation == owner),
|
orelse (FAffiliation == admin) orelse (FAffiliation == owner),
|
||||||
case xml:remove_cdata(Els) of
|
InviteEl = case xml:remove_cdata(Els) of
|
||||||
[{xmlelement, "x", _Attrs1, Els1} = XEl] ->
|
[{xmlelement, "x", _Attrs1, Els1} = XEl] ->
|
||||||
case xml:get_tag_attr_s("xmlns", XEl) of
|
case xml:get_tag_attr_s("xmlns", XEl) of
|
||||||
?NS_MUC_USER ->
|
?NS_MUC_USER ->
|
||||||
case xml:remove_cdata(Els1) of
|
ok;
|
||||||
[{xmlelement, "invite", Attrs2, _Els2} = InviteEl] ->
|
_ ->
|
||||||
case jlib:string_to_jid(
|
throw({error, ?ERR_BAD_REQUEST})
|
||||||
xml:get_attr_s("to", Attrs2)) of
|
end,
|
||||||
error ->
|
case xml:remove_cdata(Els1) of
|
||||||
error;
|
[{xmlelement, "invite", _Attrs2, _Els2} = InviteEl1] ->
|
||||||
JID ->
|
InviteEl1;
|
||||||
case CanInvite of
|
_ ->
|
||||||
true ->
|
throw({error, ?ERR_BAD_REQUEST})
|
||||||
Reason =
|
end;
|
||||||
xml:get_path_s(
|
_ ->
|
||||||
InviteEl,
|
throw({error, ?ERR_BAD_REQUEST})
|
||||||
[{elem, "reason"}, cdata]),
|
end,
|
||||||
IEl =
|
JID = case jlib:string_to_jid(
|
||||||
[{xmlelement, "invite",
|
xml:get_tag_attr_s("to", InviteEl)) of
|
||||||
[{"from",
|
error ->
|
||||||
jlib:jid_to_string(From)}],
|
throw({error, ?ERR_JID_MALFORMED});
|
||||||
[{xmlelement, "reason", [],
|
JID1 ->
|
||||||
[{xmlcdata, Reason}]}]}],
|
JID1
|
||||||
PasswdEl =
|
end,
|
||||||
case (StateData#state.config)#config.password_protected of
|
case CanInvite of
|
||||||
true ->
|
false ->
|
||||||
[{xmlelement, "password", [],
|
throw({error, ?ERR_NOT_ALLOWED});
|
||||||
[{xmlcdata, (StateData#state.config)#config.password}]}];
|
true ->
|
||||||
_ ->
|
Reason =
|
||||||
[]
|
xml:get_path_s(
|
||||||
end,
|
InviteEl,
|
||||||
Msg =
|
[{elem, "reason"}, cdata]),
|
||||||
{xmlelement, "message",
|
IEl =
|
||||||
[{"type", "normal"}],
|
[{xmlelement, "invite",
|
||||||
[{xmlelement, "x",
|
[{"from",
|
||||||
[{"xmlns", ?NS_MUC_USER}],
|
jlib:jid_to_string(From)}],
|
||||||
IEl ++ PasswdEl},
|
[{xmlelement, "reason", [],
|
||||||
{xmlelement, "x",
|
[{xmlcdata, Reason}]}]}],
|
||||||
[{"xmlns",
|
PasswdEl =
|
||||||
?NS_XCONFERENCE},
|
case (StateData#state.config)#config.password_protected of
|
||||||
{"jid",
|
true ->
|
||||||
jlib:jid_to_string(
|
[{xmlelement, "password", [],
|
||||||
{StateData#state.room,
|
[{xmlcdata, (StateData#state.config)#config.password}]}];
|
||||||
StateData#state.host,
|
_ ->
|
||||||
""})}],
|
[]
|
||||||
[{xmlcdata, Reason}]}]},
|
end,
|
||||||
ejabberd_router:route(
|
Msg =
|
||||||
StateData#state.jid,
|
{xmlelement, "message",
|
||||||
JID,
|
[{"type", "normal"}],
|
||||||
Msg),
|
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}], IEl ++ PasswdEl},
|
||||||
JID;
|
{xmlelement, "x",
|
||||||
_ ->
|
[{"xmlns", ?NS_XCONFERENCE},
|
||||||
error
|
{"jid", jlib:jid_to_string(
|
||||||
end
|
{StateData#state.room,
|
||||||
end;
|
StateData#state.host,
|
||||||
_ ->
|
""})}],
|
||||||
error
|
[{xmlcdata, Reason}]}]},
|
||||||
end;
|
ejabberd_router:route(StateData#state.jid, JID, Msg),
|
||||||
_ ->
|
JID
|
||||||
error
|
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
error
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user