]> granicus.if.org Git - ejabberd/commitdiff
Fix message routing from subscribers
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 8 Sep 2016 13:39:34 +0000 (16:39 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 8 Sep 2016 13:39:34 +0000 (16:39 +0300)
src/mod_muc_room.erl

index 11cc1d5f5a2a3d2f9a8f53acb8afe226b85db7c4..ef94c3cba0a69cbdec2985f4dc89d6869e3ebd57 100644 (file)
@@ -139,7 +139,8 @@ normal_state({route, From, <<"">>,
             StateData) ->
     Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
     case is_user_online(From, StateData) orelse
-          is_user_allowed_message_nonparticipant(From, StateData)
+       is_subscriber(From, StateData) orelse
+       is_user_allowed_message_nonparticipant(From, StateData)
        of
       true ->
          case fxml:get_attr_s(<<"type">>, Attrs) of
@@ -527,7 +528,8 @@ normal_state({route, From, ToNick,
       continue_delivery ->
          case
            {(StateData#state.config)#config.allow_private_messages,
-            is_user_online(From, StateData)}
+            is_user_online(From, StateData) orelse
+            is_subscriber(From, StateData)}
              of
            {true, true} ->
                case Type of
@@ -562,9 +564,7 @@ normal_state({route, From, ToNick,
                               PmFromVisitors == anyone;
                               (PmFromVisitors == moderators) and
                                 DstIsModerator ->
-                                  {ok, #user{nick = FromNick}} =
-                                      (?DICT):find(jid:tolower(From),
-                                                   StateData#state.users),
+                                  {FromNick, _} = get_participant_data(From, StateData),
                                   FromNickJID =
                                       jid:replace_resource(StateData#state.jid,
                                                                 FromNick),
@@ -1067,7 +1067,14 @@ get_participant_data(From, StateData) ->
        of
       {ok, #user{nick = FromNick, role = Role}} ->
          {FromNick, Role};
-      error -> {<<"">>, moderator}
+      error ->
+           case ?DICT:find(jid:tolower(jid:remove_resource(From)),
+                           StateData#state.subscribers) of
+               {ok, #subscriber{nick = FromNick}} ->
+                   {FromNick, none};
+               error ->
+                   {<<"">>, moderator}
+           end
     end.
 
 process_presence(From, Nick,