* src/mod_muc/mod_muc_room.erl: Include the error condition in the
presence status when kicking a participant due to an error stanza (EJAB-496) SVN Revision: 1179
This commit is contained in:
parent
0a6a45bf09
commit
a90606b104
|
@ -1,5 +1,9 @@
|
||||||
2008-02-08 Badlop <badlop@process-one.net>
|
2008-02-08 Badlop <badlop@process-one.net>
|
||||||
|
|
||||||
|
* src/mod_muc/mod_muc_room.erl: Include the error condition in the
|
||||||
|
presence status when kicking a participant due to an error
|
||||||
|
stanza (EJAB-496)
|
||||||
|
|
||||||
* src/ejabberd.cfg.example: Document options to SQL keep alive
|
* src/ejabberd.cfg.example: Document options to SQL keep alive
|
||||||
interval and pool size (EJAB-206)
|
interval and pool size (EJAB-206)
|
||||||
* doc/guide.tex: Likewise
|
* doc/guide.tex: Likewise
|
||||||
|
|
|
@ -294,18 +294,11 @@ normal_state({route, From, "",
|
||||||
"error" ->
|
"error" ->
|
||||||
case is_user_online(From, StateData) of
|
case is_user_online(From, StateData) of
|
||||||
true ->
|
true ->
|
||||||
NewState =
|
ErrorText = "This participant is kicked from the room because "
|
||||||
add_user_presence_un(
|
"he sent an error message",
|
||||||
From,
|
NewState = expulse_participant(Packet, From, StateData,
|
||||||
{xmlelement, "presence",
|
translate:translate(Lang, ErrorText)),
|
||||||
[{"type", "unavailable"}],
|
{next_state, normal_state, NewState};
|
||||||
[{xmlelement, "status", [],
|
|
||||||
[{xmlcdata,
|
|
||||||
"This participant sent a bad error message to the room."}]}]},
|
|
||||||
StateData),
|
|
||||||
send_new_presence(From, NewState),
|
|
||||||
{next_state, normal_state,
|
|
||||||
remove_online_user(From, NewState)};
|
|
||||||
_ ->
|
_ ->
|
||||||
{next_state, normal_state, StateData}
|
{next_state, normal_state, StateData}
|
||||||
end;
|
end;
|
||||||
|
@ -902,16 +895,10 @@ process_presence(From, Nick, {xmlelement, "presence", Attrs, _Els} = Packet,
|
||||||
"error" ->
|
"error" ->
|
||||||
case is_user_online(From, StateData) of
|
case is_user_online(From, StateData) of
|
||||||
true ->
|
true ->
|
||||||
NewState =
|
ErrorText = "This participant is kicked from the room because "
|
||||||
add_user_presence_un(
|
"he sent an error presence",
|
||||||
From,
|
expulse_participant(Packet, From, StateData,
|
||||||
{xmlelement, "presence",
|
translate:translate(Lang, ErrorText));
|
||||||
[{"type", "unavailable"}],
|
|
||||||
[{xmlelement, "status", [],
|
|
||||||
[{xmlcdata, "This participant sent a bad error presence."}]}]},
|
|
||||||
StateData),
|
|
||||||
send_new_presence(From, NewState),
|
|
||||||
remove_online_user(From, NewState);
|
|
||||||
_ ->
|
_ ->
|
||||||
StateData
|
StateData
|
||||||
end;
|
end;
|
||||||
|
@ -1040,9 +1027,7 @@ decide_fate_message(_, _, _, _) ->
|
||||||
%% that the sender is a dead participant.
|
%% that the sender is a dead participant.
|
||||||
%% If so, return true to kick the participant.
|
%% If so, return true to kick the participant.
|
||||||
check_error_kick(Packet) ->
|
check_error_kick(Packet) ->
|
||||||
{xmlelement, _, _, EEls} = xml:get_subtag(Packet, "error"),
|
case get_error_condition(Packet) of
|
||||||
[{xmlelement, Name, _, _}] = xml:remove_cdata(EEls),
|
|
||||||
case Name of
|
|
||||||
"gone" -> true;
|
"gone" -> true;
|
||||||
"internal-server-error" -> true;
|
"internal-server-error" -> true;
|
||||||
"item-not-found" -> true;
|
"item-not-found" -> true;
|
||||||
|
@ -1055,6 +1040,32 @@ check_error_kick(Packet) ->
|
||||||
_ -> false
|
_ -> false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
get_error_condition(Packet) ->
|
||||||
|
case catch get_error_condition2(Packet) of
|
||||||
|
{condition, ErrorCondition} ->
|
||||||
|
ErrorCondition;
|
||||||
|
{'EXIT', Error} ->
|
||||||
|
"badformed error stanza"
|
||||||
|
end.
|
||||||
|
get_error_condition2(Packet) ->
|
||||||
|
{xmlelement, _, _, EEls} = xml:get_subtag(Packet, "error"),
|
||||||
|
[Condition] = [Name || {xmlelement, Name, [{"xmlns", ?NS_STANZAS}], []} <- EEls],
|
||||||
|
{condition, Condition}.
|
||||||
|
|
||||||
|
expulse_participant(Packet, From, StateData, Reason1) ->
|
||||||
|
ErrorCondition = get_error_condition(Packet),
|
||||||
|
Reason2 = io_lib:format(Reason1 ++ ": " ++ "~s", [ErrorCondition]),
|
||||||
|
NewState = add_user_presence_un(
|
||||||
|
From,
|
||||||
|
{xmlelement, "presence",
|
||||||
|
[{"type", "unavailable"}],
|
||||||
|
[{xmlelement, "status", [],
|
||||||
|
[{xmlcdata, Reason2}]
|
||||||
|
}]},
|
||||||
|
StateData),
|
||||||
|
send_new_presence(From, NewState),
|
||||||
|
remove_online_user(From, NewState).
|
||||||
|
|
||||||
|
|
||||||
set_affiliation(JID, Affiliation, StateData) ->
|
set_affiliation(JID, Affiliation, StateData) ->
|
||||||
LJID = jlib:jid_remove_resource(jlib:jid_tolower(JID)),
|
LJID = jlib:jid_remove_resource(jlib:jid_tolower(JID)),
|
||||||
|
|
Loading…
Reference in New Issue