]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_muc/mod_muc_room.erl: MUC kicks a participant if sends a
authorBadlop <badlop@process-one.net>
Wed, 9 Jan 2008 16:01:16 +0000 (16:01 +0000)
committerBadlop <badlop@process-one.net>
Wed, 9 Jan 2008 16:01:16 +0000 (16:01 +0000)
private message with type=error (EJAB-496)

SVN Revision: 1142

ChangeLog
src/mod_muc/mod_muc_room.erl

index 70decbd005bbc69a057b7fea5ec108c93d4f66a2..db6df403a4a049e7561a1550f1fcda6d5dc01840 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-09  Badlop  <badlop@process-one.net>
+
+       * src/mod_muc/mod_muc_room.erl: MUC kicks a participant if sends a
+       private message with type=error (EJAB-496)
+
 2008-01-08  Badlop  <badlop@process-one.net>
 
        * src/ejabberdctl.template: Removed the option ERL_FULLSWEEP_AFTER
index b738cee07546f70b34761863b7e51a13c3a199ce..b6a8c949d5490fe6ac2a2af9ebc9bfe1cef28c7f 100644 (file)
@@ -469,71 +469,53 @@ normal_state({route, From, ToNick,
             StateData) ->
     Type = xml:get_attr_s("type", Attrs),
     Lang = xml:get_attr_s("xml:lang", Attrs),
-    case Type of
-       "error" ->
-           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)};
+    case (StateData#state.config)#config.allow_private_messages
+       andalso is_user_online(From, StateData) of
+       true ->
+           case Type of
+               "groupchat" ->
+                   ErrText = "It is not allowed to send private "
+                       "messages of type \"groupchat\"",
+                   Err = jlib:make_error_reply(
+                           Packet, ?ERRT_BAD_REQUEST(Lang, ErrText)),
+                   ejabberd_router:route(
+                     jlib:jid_replace_resource(
+                       StateData#state.jid,
+                       ToNick),
+                     From, Err);
                _ ->
-                   {next_state, normal_state, StateData}
-           end;
-       _ ->
-           case (StateData#state.config)#config.allow_private_messages
-               andalso is_user_online(From, StateData) of
-               true ->
-                   case Type of
-                       "groupchat" ->
-                           ErrText = "It is not allowed to send private "
-                                     "messages of type \"groupchat\"",
+                   case find_jid_by_nick(ToNick, StateData) of
+                       false ->
+                           ErrText = "Recipient is not in the conference room",
                            Err = jlib:make_error_reply(
-                                   Packet, ?ERRT_BAD_REQUEST(Lang, ErrText)),
+                                   Packet, ?ERRT_ITEM_NOT_FOUND(Lang, ErrText)),
                            ejabberd_router:route(
-                               jlib:jid_replace_resource(
-                                   StateData#state.jid,
-                                   ToNick),
-                               From, Err);
-                       _ ->
-                           case find_jid_by_nick(ToNick, StateData) of
-                               false ->
-                                   ErrText = "Recipient is not in the conference room",
-                                   Err = jlib:make_error_reply(
-                                           Packet, ?ERRT_ITEM_NOT_FOUND(Lang, ErrText)),
-                                   ejabberd_router:route(
-                                       jlib:jid_replace_resource(
-                                           StateData#state.jid,
-                                           ToNick),
-                                       From, Err);
-                               ToJID ->
-                                   {ok, #user{nick = FromNick}} =
-                                       ?DICT:find(jlib:jid_tolower(From),
-                                               StateData#state.users),
-                                   ejabberd_router:route(
-                                       jlib:jid_replace_resource(
-                                           StateData#state.jid,
-                                           FromNick),
-                                       ToJID, Packet)
-                           end
-                   end;
-               _ ->
-                   ErrText = "Only occupants are allowed to send messages to the conference",
-                   Err = jlib:make_error_reply(
-                           Packet, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)),
-                   ejabberd_router:route(
-                       jlib:jid_replace_resource(
-                           StateData#state.jid,
-                           ToNick),
-                       From, Err)
-           end,
-           {next_state, normal_state, StateData}
-    end;
+                             jlib:jid_replace_resource(
+                               StateData#state.jid,
+                               ToNick),
+                             From, Err);
+                       ToJID ->
+                           {ok, #user{nick = FromNick}} =
+                               ?DICT:find(jlib:jid_tolower(From),
+                                          StateData#state.users),
+                           ejabberd_router:route(
+                             jlib:jid_replace_resource(
+                               StateData#state.jid,
+                               FromNick),
+                             ToJID, Packet)
+                   end
+           end;
+       _ ->
+           ErrText = "Only occupants are allowed to send messages to the conference",
+           Err = jlib:make_error_reply(
+                   Packet, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)),
+           ejabberd_router:route(
+             jlib:jid_replace_resource(
+               StateData#state.jid,
+               ToNick),
+             From, Err)
+    end,
+    {next_state, normal_state, StateData};
 
 normal_state({route, From, ToNick,
              {xmlelement, "iq", Attrs, _Els} = Packet},