25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

mod_muc_room.erl: Fix bug in MUC invite.

SVN Revision: 1736
This commit is contained in:
Pablo Polvorin 2008-12-17 16:24:15 +00:00
parent 69805f36fa
commit d3ddf10839
2 changed files with 24 additions and 18 deletions

View File

@ -1,3 +1,7 @@
2008-12-17 Pablo Polvorin <pablo.polvorin@process-one.net>
* src/mod_muc/mod_muc_room.erl: Fix bug in MUC invite.
2008-12-17 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-12-17 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
Merge from trunk (r1730 to r1734). Merge from trunk (r1730 to r1734).

View File

@ -261,7 +261,7 @@ normal_state({route, From, undefined,
StateData#state.jid, StateData#state.jid,
From, exmpp_stanza:reply_with_error(Packet, Err)), From, exmpp_stanza:reply_with_error(Packet, Err)),
{next_state, normal_state, StateData}; {next_state, normal_state, StateData};
normal -> Type when (Type == 'normal') orelse (Type == 'undefined') ->
case catch check_invitation(From, case catch check_invitation(From,
exmpp_xml:get_child_elements(Packet), exmpp_xml:get_child_elements(Packet),
Lang, Lang,
@ -884,7 +884,7 @@ process_presence(From, Nick, #xmlel{name = 'presence'} = Packet,
_ -> _ ->
StateData StateData
end; end;
available -> 'available' ->
case is_user_online(From, StateData) of case is_user_online(From, StateData) of
true -> true ->
case is_nick_change(From, Nick, StateData) of case is_nick_change(From, Nick, StateData) of
@ -3236,23 +3236,24 @@ check_invitation(From, Els, Lang, StateData) ->
InviteEl, InviteEl,
[{element, 'reason'}, cdata]), [{element, 'reason'}, cdata]),
ContinueEl = ContinueEl =
case xml:get_path( case exmpp_xml:get_path(
InviteEl, InviteEl,
[{element, 'continue'}]) of [{element, 'continue'}]) of
[] -> []; 'undefined' -> [];
Continue1 -> [Continue1] Continue1 -> [Continue1]
end, end,
IEl = IEl =
[#xmlel{name = 'invite', [#xmlel{ns = ?NS_MUC_USER,
name = 'invite',
attrs = [#xmlattr{name = 'from', attrs = [#xmlattr{name = 'from',
value = exmpp_jid:jid_to_list(From)}], value = exmpp_jid:jid_to_list(From)}],
children = [#xmlel{name = 'reason', children = [#xmlel{ns =?NS_MUC_USER, name = 'reason',
children = [#xmlcdata{cdata = Reason} ]}] children = [#xmlcdata{cdata = Reason} ]}]
++ ContinueEl}], ++ ContinueEl}],
PasswdEl = PasswdEl =
case (StateData#state.config)#config.password_protected of case (StateData#state.config)#config.password_protected of
true -> true ->
[#xmlel{name = 'password', [#xmlel{ns = ?NS_MUC_USER, name = 'password',
children = [#xmlcdata{cdata = children = [#xmlcdata{cdata =
(StateData#state.config)#config.password}]}]; (StateData#state.config)#config.password}]}];
_ -> _ ->
@ -3261,7 +3262,7 @@ check_invitation(From, Els, Lang, StateData) ->
Body = Body =
#xmlel{name = 'body', #xmlel{name = 'body',
children = [#xmlcdata{cdata = children = [#xmlcdata{cdata =
lists:flatten( list_to_binary([
io_lib:format( io_lib:format(
translate:translate(Lang, translate:translate(Lang,
"~s invites you to the room ~s"), "~s invites you to the room ~s"),
@ -3269,7 +3270,7 @@ check_invitation(From, Els, Lang, StateData) ->
exmpp_jid:jid_to_list(StateData#state.room, exmpp_jid:jid_to_list(StateData#state.room,
StateData#state.host, StateData#state.host,
"") "")
])) ++ ]),
case (StateData#state.config)#config.password_protected of case (StateData#state.config)#config.password_protected of
true -> true ->
", " ++ ", " ++
@ -3278,14 +3279,15 @@ check_invitation(From, Els, Lang, StateData) ->
(StateData#state.config)#config.password ++ "'"; (StateData#state.config)#config.password ++ "'";
_ -> _ ->
"" ""
end ++ end,
case Reason of case Reason of
"" -> ""; <<>> -> "";
_ -> " (" ++ Reason ++ ") " _ -> [" (", Reason, ") "]
end end
}]}, ])}]},
%%TODO: always NS_JABER_CLIENT?
Msg = Msg =
#xmlel{name = 'message', #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message',
attrs = [#xmlattr{name = 'type', value = "normal"}], attrs = [#xmlattr{name = 'type', value = "normal"}],
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x', children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
children = IEl ++ PasswdEl}, children = IEl ++ PasswdEl},