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

* src/mod_muc/mod_muc_room.erl: Remove user from room on receiving

of message or presence error from him

SVN Revision: 108
This commit is contained in:
Alexey Shchepin 2003-05-14 19:58:05 +00:00
parent 481cc2d1f4
commit 2d3aa901a9
2 changed files with 81 additions and 26 deletions

View File

@ -1,3 +1,8 @@
2003-05-14 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc_room.erl: Remove user from room on receiving
of message or presence error from him
2003-05-12 Alexey Shchepin <alexey@sevcom.net> 2003-05-12 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_s2s_out.erl: Fixed error replies, added timeouts * src/ejabberd_s2s_out.erl: Fixed error replies, added timeouts

View File

@ -189,7 +189,20 @@ normal_state({route, From, "",
{next_state, normal_state, StateData} {next_state, normal_state, StateData}
end; end;
"error" -> "error" ->
{next_state, normal_state, StateData}; case is_user_online(From, StateData) of
true ->
NewState =
add_user_presence_un(
From,
{xmlelement, "presence",
[{"type", "unavailable"}], []},
StateData),
send_new_presence(From, NewState),
{next_state, normal_state,
remove_online_user(From, NewState)};
_ ->
{next_state, normal_state, StateData}
end;
Type when (Type == "") or (Type == "normal") -> Type when (Type == "") or (Type == "normal") ->
case check_invitation(From, Els, StateData) of case check_invitation(From, Els, StateData) of
error -> error ->
@ -296,8 +309,20 @@ normal_state({route, From, Nick,
_ -> _ ->
StateData StateData
end; end;
"error" -> % TODO "error" ->
StateData; case is_user_online(From, StateData) of
true ->
NewState =
add_user_presence_un(
From,
{xmlelement, "presence",
[{"type", "unavailable"}], []},
StateData),
send_new_presence(From, NewState),
remove_online_user(From, NewState);
_ ->
StateData
end;
"" -> "" ->
case is_user_online(From, StateData) of case is_user_online(From, StateData) of
true -> true ->
@ -388,31 +413,56 @@ normal_state({route, From, Nick,
normal_state({route, From, ToNick, normal_state({route, From, ToNick,
{xmlelement, "message", Attrs, Els} = Packet}, {xmlelement, "message", Attrs, Els} = Packet},
StateData) -> StateData) ->
case (StateData#state.config)#config.allow_private_messages case xml:get_attr_s("type", Attrs) of
andalso is_user_online(From, StateData) of "error" ->
true -> case is_user_online(From, StateData) of
case find_jid_by_nick(ToNick, StateData) of true ->
false -> NewState =
Err = jlib:make_error_reply( add_user_presence_un(
Packet, ?ERR_JID_NOT_FOUND), From,
ejabberd_router:route( {xmlelement, "presence",
{StateData#state.room, StateData#state.host, ToNick}, [{"type", "unavailable"}], []},
From, Err); StateData),
ToJID -> send_new_presence(From, NewState),
{ok, #user{nick = FromNick}} = {next_state, normal_state,
?DICT:find(jlib:jid_tolower(From), remove_online_user(From, NewState)};
StateData#state.users), _ ->
ejabberd_router:route( {next_state, normal_state, StateData}
{StateData#state.room, StateData#state.host, FromNick},
ToJID, Packet)
end; end;
_ -> _ ->
Err = jlib:make_error_reply( case (StateData#state.config)#config.allow_private_messages
Packet, ?ERR_NOT_ALLOWED), andalso is_user_online(From, StateData) of
ejabberd_router:route( true ->
{StateData#state.room, StateData#state.host, ToNick}, From, Err) case find_jid_by_nick(ToNick, StateData) of
end, false ->
{next_state, normal_state, StateData}; Err = jlib:make_error_reply(
Packet, ?ERR_JID_NOT_FOUND),
ejabberd_router:route(
{StateData#state.room,
StateData#state.host,
ToNick},
From, Err);
ToJID ->
{ok, #user{nick = FromNick}} =
?DICT:find(jlib:jid_tolower(From),
StateData#state.users),
ejabberd_router:route(
{StateData#state.room,
StateData#state.host,
FromNick},
ToJID, Packet)
end,
{next_state, normal_state, StateData};
_ ->
Err = jlib:make_error_reply(
Packet, ?ERR_NOT_ALLOWED),
ejabberd_router:route(
{StateData#state.room,
StateData#state.host,
ToNick}, From, Err),
{next_state, normal_state, StateData}
end
end;
normal_state({route, From, ToNick, normal_state({route, From, ToNick,
{xmlelement, "iq", Attrs, Els} = Packet}, {xmlelement, "iq", Attrs, Els} = Packet},