mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
Use pattern matching in check_voice_request_fields/2 and check_voice_approvement_fields/2
This commit is contained in:
parent
eb8347f92b
commit
faed7698c2
@ -3752,23 +3752,18 @@ is_voice_request(Els) ->
|
|||||||
end
|
end
|
||||||
end, false, Els).
|
end, false, Els).
|
||||||
|
|
||||||
check_voice_request_fields({Field, Value}, Acc) ->
|
check_voice_request_fields(_, false) ->
|
||||||
if Acc ->
|
false;
|
||||||
case Field of
|
check_voice_request_fields({"FORM_TYPE", "http://jabber.org/protocol/muc#request"}, true) ->
|
||||||
"FORM_TYPE" ->
|
true;
|
||||||
case Value of
|
check_voice_request_fields({"FORM_TYPE", _}, _) ->
|
||||||
"http://jabber.org/protocol/muc#request" ->
|
false;
|
||||||
true
|
check_voice_request_fields({"muc#role", "participant"}, true) ->
|
||||||
end;
|
true;
|
||||||
"muc#role" ->
|
check_voice_request_fields({"muc#role", _}, _) ->
|
||||||
case Value of
|
false;
|
||||||
"participant" ->
|
check_voice_request_fields(_, true) ->
|
||||||
true
|
true. % silently ignore any extra fields
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
true % silently ignore any extra fields
|
|
||||||
end
|
|
||||||
end.
|
|
||||||
|
|
||||||
prepare_request_form(Requester, Nick, Lang) ->
|
prepare_request_form(Requester, Nick, Lang) ->
|
||||||
{xmlelement, "message", [{"type", "normal"}], [
|
{xmlelement, "message", [{"type", "normal"}], [
|
||||||
@ -3830,35 +3825,24 @@ is_voice_approvement(Els) ->
|
|||||||
end
|
end
|
||||||
end, false, Els).
|
end, false, Els).
|
||||||
|
|
||||||
check_voice_approvement_fields({Field, Value}, Acc) ->
|
check_voice_approvement_fields(_, false) ->
|
||||||
if Acc ->
|
false;
|
||||||
case Field of
|
check_voice_approvement_fields({"FORM_TYPE", "http://jabber.org/protocol/muc#request"}, true) ->
|
||||||
"FORM_TYPE" ->
|
true;
|
||||||
case Value of
|
check_voice_approvement_fields({"FORM_TYPE", _}, _) ->
|
||||||
"http://jabber.org/protocol/muc#request" ->
|
false;
|
||||||
true
|
check_voice_approvement_fields({"muc#role", "participant"}, true) ->
|
||||||
end;
|
true;
|
||||||
"muc#role" ->
|
check_voice_approvement_fields({"muc#role", _}, _) ->
|
||||||
case Value of
|
false;
|
||||||
"participant" ->
|
check_voice_approvement_fields({"muc#request_allow", "true"}, true) ->
|
||||||
true
|
true;
|
||||||
end;
|
check_voice_approvement_fields({"muc#request_allow", "1"}, true) ->
|
||||||
"muc#jid" ->
|
true;
|
||||||
true; % TODO: make some validation here
|
check_voice_approvement_fields({"muc#request_allow", _}, _) ->
|
||||||
"muc#roomnick" ->
|
false;
|
||||||
true;
|
check_voice_approvement_fields(_, true) ->
|
||||||
"muc#request_allow" ->
|
true; % do not check any other fields
|
||||||
% XXX: submitted forms with request_allow unchecked ignored here
|
|
||||||
case Value of
|
|
||||||
"true" ->
|
|
||||||
true;
|
|
||||||
"1" ->
|
|
||||||
true
|
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
true % ignore unknown fields
|
|
||||||
end
|
|
||||||
end.
|
|
||||||
|
|
||||||
extract_jid_from_voice_approvement(Els) ->
|
extract_jid_from_voice_approvement(Els) ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
|
Loading…
Reference in New Issue
Block a user