The macro-systemrecording code does not use a temp file to allow for safe re-recording of existing recordings. It appears, actually, that one of the first things it does is remove any copy of the existing recording, which could have undesirable results in a production environment in the event of a recording mishap.
I propose the macro be changed to create a temporary copy of the existing recording, and then work against that temporary file until the user is satisfied with the results. Once they accept the final recording, then copy the temporary file over the original and delete the temporary file.
This would also result in changes to the keys pressed to perform the actions, but that change is fairly minor.
I also made authentication the first order of business. I figured there was no point doing anything unless the user can authenticate.
The main focus, though, is the use of temporary files and actually making the user accept the recording.
I have already made such a change against a test server, and it seems to work fine for using the web-based system recording with *77 and *99, as well as feature code re-recording of existing recordings. The code was posted to the forums for everyone to see, but I thought that perhaps it would be a good feature request as well.
I am not a programmer and do not fully understand how everything ties together, so I'm sure there's some room for improvement in my changes. I was especially having trouble with the copying of the files.
My changed code is below, with all of the debugging NoOps? removed for brevity:
[macro-systemrecording]
exten => s,1,ExecIf($["${ARG3}" != ""],Authenticate,${ARG3})
exten => s,n,Set(MYRECFILE=${IF($["${ARG2}" = ""]?/tmp/${AMPUSER}-ivrrecording:${ASTVARLIBDIR}/sounds/${ARG2})})
exten => s,n,Set(MYTMPRECFILE=${IF($["${ARG2}" = ""]?/tmp/${AMPUSER}-ivrrecording-tmp:${ASTVARLIBDIR}/sounds/${ARG2}-tmp)})
exten => s,n,System(cp ${MYRECFILE}.wav ${MYTMPRECFILE}.wav)
exten => s,n,Goto(${ARG1},1)
exten => dorecord,1,Background(say-temp-msg-prs-pound)
exten => dorecord,n,Record(${MYTMPRECFILE}:wav)
exten => dorecord,n,Wait(1)
exten => dorecord,n,Goto(confmenu,1)
exten => docheck,1,Playback(beep)
exten => docheck,n(dc_start),Background(${MYTMPRECFILE},m,${LANGUAGE},macro-systemrecording)
exten => docheck,n,Wait(1)
exten => docheck,n,Goto(confmenu,1)
exten => doaccept,1,System(cp ${MYTMPRECFILE}.wav ${MYRECFILE}.wav)
exten => doaccept,n,System(rm ${MYTMPRECFILE}.*)
exten => doaccept,n,Playback(auth-thankyou)
exten => doaccept,n,Wait(1)
exten => doaccept,n,Hangup
exten => confmenu,1,Background(to-listen-to-it&press-1&to-accept-recording&press-2&to-rerecord-it&press-3,m,${LANGUAGE},macro-systemrecording)
exten => confmenu,n,Read(RECRESULT,,1,,,4)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x3"]?dorecord,1)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x1"]?docheck,dc_start)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x2"]?doaccept,1)
exten => confmenu,n,Goto(1)
exten => 1,1,Goto(docheck,dc_start)
exten => 3,1,Goto(dorecord,1)
exten => t,1,Playback(goodbye)
exten => t,n,Hangup
exten => i,1,Playback(pm-invalid-option)
exten => i,n,Goto(confmenu,1)
exten => h,1,Hangup
; end of [macro-systemrecording]