diff options
author | Maxim Ignatenko <gelraen.ua@gmail.com> | 2011-09-20 20:27:08 +0300 |
---|---|---|
committer | Maxim Ignatenko <gelraen.ua@gmail.com> | 2011-09-26 11:16:29 +0300 |
commit | f919349173d8dae2d895b3419057ea453663be5c (patch) | |
tree | bd397bc00f49768c6621bee932d7ecd7d7e28242 | |
parent | Remove try/catch (diff) |
Use more pattern-matching
-rw-r--r-- | src/mod_muc/mod_muc_room.erl | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index bd26b74d0..c191c4122 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -3735,18 +3735,12 @@ is_voice_request({xmlelement, "x", _, _} = Elem) -> end; is_voice_request(Els) -> lists:foldl( - fun(X, Acc) -> - case Acc of - false -> - case X of - {xmlelement, "x", _, _} -> - is_voice_request(X); - _ -> - false - end; - true -> - true - end + fun(_, true) -> + true; + ({xmlelement, "x", _, _} = X, false) -> + is_voice_request(X); + (_, _) -> + false end, false, Els). check_voice_request_fields(_, false) -> @@ -3805,18 +3799,12 @@ is_voice_approvement({xmlelement, "x", _, _} = Elem) -> end; is_voice_approvement(Els) -> lists:foldl( - fun(X, Acc) -> - case Acc of - false -> - case X of - {xmlelement, "x", _, _} -> - is_voice_approvement(X); - _ -> - false - end; - true -> - true - end + fun(_, true) -> + true; + ({xmlelement, "x", _, _} = X, false) -> + is_voice_approvement(X); + (_, _) -> + false end, false, Els). check_voice_approvement_fields(_, false) -> @@ -3836,7 +3824,7 @@ check_voice_approvement_fields({"muc#request_allow", "1"}, true) -> check_voice_approvement_fields({"muc#request_allow", _}, _) -> false; check_voice_approvement_fields(_, true) -> - true; % do not check any other fields + true. % do not check any other fields extract_jid_from_voice_approvement(Els) -> lists:foldl( |