diff options
author | Maxim Ignatenko <gelraen.ua@gmail.com> | 2011-07-23 17:13:27 +0300 |
---|---|---|
committer | Maxim Ignatenko <gelraen.ua@gmail.com> | 2011-09-26 11:16:27 +0300 |
commit | f175be6b785702fab558f333fd2933ab38ff7411 (patch) | |
tree | 19b39983716dbac907cf491ae3676b5c56ea5ff7 /src/mod_muc/mod_muc_room.erl | |
parent | More correct dispatching of normal messages to conference room (diff) |
Add function for detecting voice requests
Diffstat (limited to 'src/mod_muc/mod_muc_room.erl')
-rw-r--r-- | src/mod_muc/mod_muc_room.erl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index a0ff8df5..c8623c10 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -257,6 +257,7 @@ normal_state({route, From, "", {next_state, normal_state, StateData}; Type when (Type == "") or (Type == "normal") -> IsInvitation = is_invitation(Els), + IsVoiceRequest = is_voice_request(Els), if IsInvitation -> case catch check_invitation(From, Els, Lang, StateData) of @@ -295,6 +296,8 @@ normal_state({route, From, "", {next_state, normal_state, StateData} end end; + IsVoiceRequest -> + {next_state, normal_state, StateData}; true -> {next_state, normal_state, StateData} end; @@ -3627,6 +3630,48 @@ get_mucroom_disco_items(StateData) -> ?DICT:to_list(StateData#state.users)). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Voice request support + +is_voice_request(Els) -> + try + case xml:remove_cdata(Els) of + [{xmlelement, "x", _, Els1} = XEl] -> + case xml:get_attr_s("xmlns", XEl) of + ?NS_XDATA -> + lists:foldl(check_voice_requests_fields, true, Els1) + end + end + catch + _ -> + false + end. + +check_voice_request_fields({xmlelement, "field", _, Els} = Elem, Acc) -> + try + case Acc of + true -> + case xml:get_attr_s("var", Elem) of + "FORM_TYPE" -> + [{xmlelement, "value", _, Value}] = Els, + case xml:get_cdata(Value) of + "http://jabber.org/protocol/muc#request" -> + true + end; + "muc#role" -> + [{xmlelement, "value", _, Value}] = Els, + case xml:get_cdata(Value) of + "participant" -> + true + end + end + end + catch + _ -> + false + end. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Invitation support is_invitation(Els) -> |