Multi-condition extensions with break=never not working as intended

Status
Not open for further replies.

czbg

Member
Sep 27, 2018
33
1
8
I've found out that any multi-condition extension, which uses break=never does not work. I was trying to set call recording and had troubles with defined call direction recording. First problem is call direction, which is always empty but I'll write about that in another thread. If direction is ok, recording still does not work as intended, because of break=never, which means that if the last conditon matches, action is set to execute, even though the conditions before were not met.

I've found the bug report which describes similar situation: https://freeswitch.org/jira/browse/FS-4935

FS logical AND works only w/o break=never. I've solved this by rewriting user_record extension in XML, because there is no way to define condition regex="all" in the FPBX.

My working user_record is below:
Code:
<extension name="user_record" continue="true" uuid="7fa775b3-f465-46e3-94a4-a03258f9ec3f">
    <condition field="" expression="">
        <action application="set" data="user_record=${user_data ${destination_number}@${domain_name} var user_record}" inline="true"/>
        <action application="set" data="from_user_exists=${user_exists id ${sip_from_user} ${sip_from_host}}" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${user_exists}" expression="^true$"/>
        <regex field="${user_record}" expression="^all$"/>
        <action application="set" data="record_session=true" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${user_exists}" expression="^true$"/>
        <regex field="${call_direction}" expression="^inbound$"/>
        <regex field="${user_record}" expression="^inbound$"/>
        <action application="set" data="record_session=true" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${user_exists}" expression="^true$"/>
        <regex field="${call_direction}" expression="^outbound$"/>
        <regex field="${user_record}" expression="^outbound$"/>
        <action application="set" data="record_session2=true" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${user_exists}" expression="^true$"/>
        <regex field="${call_direction}" expression="^local$"/>
        <regex field="${user_record}" expression="^local$"/>
        <action application="set" data="record_session=true" inline="true"/>
    </condition>
    <condition field="${from_user_exists}" expression="^true$" break="never">
        <action application="set" data="from_user_record=${user_data ${sip_from_user}@${sip_from_host} var user_record}" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${from_user_exists}" expression="^true$"/>
        <regex field="${from_user_record}" expression="^all$"/>
        <action application="set" data="record_session=true" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${from_user_exists}" expression="^true$"/>
        <regex field="${call_direction}" expression="^inbound$"/>
        <regex field="${from_user_record}" expression="^inbound$"/>
        <action application="set" data="record_session=true" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${from_user_exists}" expression="^true$"/>
        <regex field="${call_direction}" expression="^outbound$"/>
        <regex field="${from_user_record}" expression="^outbound$"/>
        <action application="set" data="record_session=true" inline="true"/>
    </condition>
    <condition regex="all" break="never">
        <regex field="${from_user_exists}" expression="^true$"/>
        <regex field="${call_direction}" expression="^local$"/>
        <regex field="${from_user_record}" expression="^local$"/>
        <action application="set" data="record_session=true" inline="true"/>
    </condition>
    <condition field="${record_session}" expression="^true$">
        <action application="set" data="record_path=${recordings_dir}/${domain_name}/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}" inline="true"/>
        <action application="set" data="record_name=${uuid}_${caller_id_number}_${destination_number}_${strftime(%Y%m%d%H%M)}.${record_ext}" inline="true"/>
        <action application="set" data="recording_follow_transfer=true" inline="true"/>
        <action application="set" data="record_append=true" inline="true"/>
        <action application="set" data="record_in_progress=true" inline="true"/>
        <action application="set" data="${uuid_record ${uuid} start ${record_path}/${record_name}}" inline="false"/>
    </condition>
</extension>
 
Status
Not open for further replies.