From 36ab9cc2ea4ac1163905b178e3692e9578064524 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Thu, 8 Sep 2016 16:39:34 +0300 Subject: [PATCH] Fix message routing from subscribers --- src/mod_muc_room.erl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 11cc1d5f5..ef94c3cba 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -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, -- 2.40.0