fm_enable_voicemail wipes an existing mailbox's email and option flags - #43
Open
OlivierRunwolf wants to merge 1 commit into
Open
fm_enable_voicemail wipes an existing mailbox's email and option flags#43OlivierRunwolf wants to merge 1 commit into
OlivierRunwolf wants to merge 1 commit into
Conversation
addMailbox() rewrites the mailbox's entire voicemail.conf line
(pwd,name,email,pager,options) and re-derives the novmpw/novmstar AstDB
flags from whatever it is handed. The call site passed a fixed
email => '' plus attach/envelope/vmdelete/saycid all 'no', and passed
neither passlogin nor novmstar.
On a new mailbox that is correct. On a mailbox that already exists it
destroys the voicemail-to-email address, resets all four option flags, and
clears the "require password to log in" and "disable * for voicemail"
flags. Re-running enable to change nothing, or calling it after a disable,
silently loses the email.
Read the box with getMailbox() first and feed every field back in.
Anything not modelled by name survives too: the existing option string is
passed through as 'options', which addMailbox() parses before applying the
individual keys, so imapuser/imappassword and friends are carried. The
AstDB flags are read back and re-asserted; if AstDB can't be read we omit
them and leave the previous behaviour rather than guessing.
email, attach, envelope, saycid and vmdelete are now accepted as params,
since without them there is no way to set the fields this commit starts
preserving. password now defaults to the mailbox's current PIN instead of
1234, so enabling twice no longer resets it. New mailboxes are unaffected
and still get the previous defaults.
Tested on FreePBX 17.0.30 / Asterisk 18:
fwconsole frogman:tool fm_add_extension '{"ext":"9003","name":"UpstreamVmTest","vm":"yes","vmpwd":"9933","email":"olivier@tractiondk.com","confirm":true}'
-> 9003=9933,UpstreamVmTest,olivier@tractiondk.com,,attach=no|saycid=no|envelope=no|delete=no
fwconsole frogman:tool fm_enable_voicemail '{"ext":"9003","attach":"yes","envelope":"yes","confirm":true}'
-> 9003=9933,UpstreamVmTest,olivier@tractiondk.com,,attach=yes|saycid=no|envelope=yes|delete=no
fwconsole frogman:tool fm_enable_voicemail '{"ext":"9003","confirm":true}' # was the bug
-> unchanged; email, PIN and both flags preserved
fwconsole frogman:tool fm_disable_voicemail '{"ext":"9003","confirm":true}'
fwconsole frogman:tool fm_enable_voicemail '{"ext":"9003","password":"7788","confirm":true}'
-> 9003=7788,UpstreamVmTest,,,attach=no|saycid=no|envelope=no|delete=no # new box, clean defaults
fwconsole frogman:tool fm_enable_voicemail '{"ext":"9003"}' # dry run
-> "Would update the EXISTING voicemail box 9003 ... preserved."
The users.voicemail wiring is untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
addMailbox()rewrites the mailbox's entirevoicemail.confline (pwd,name,email,pager,options) and re-derives thenovmpw/novmstarAstDB flags from whatever it's handed. The call site passed a fixedemail => ''plusattach/envelope/vmdelete/saycidall'no', and passed neitherpassloginnornovmstar.On a new mailbox that's correct. On a mailbox that already exists it destroys the voicemail-to-email address, resets all four option flags, and clears "require password to log in" and "disable * for voicemail".
The email is gone and the PIN is back to 1234. It's reachable by re-running enable to change nothing, or by enabling after a disable.
The fix
Read the box with
getMailbox()first and feed every field back in.Anything not modelled by name survives too: the existing option string is passed through as
options, whichaddMailbox()parses before applying the individual keys, soimapuser/imappasswordand anything else stored there are carried. The AstDB flags are read back and re-asserted — and if AstDB can't be read we omit them entirely and leave the previous behaviour rather than guessing.email,attach,envelope,saycidandvmdeleteare now accepted as params. I added them because without them there's no way to set the fields this PR starts preserving —fm_set_extension_emailis the only existing route to any of them. If you'd rather keep this to a pure bug fix, say the word and I'll drop the params and resubmit — the preservation logic stands on its own.passwordnow defaults to the mailbox's current PIN instead of1234, so enabling twice no longer resets it. New mailboxes are unaffected and still get the previous defaults.The
users.voicemailwiring from #36 is untouched.Testing
FreePBX 17.0.30 / Asterisk 18, real box, on top of current
main.One coverage note:
users.voicemailwas alreadydefaultat create on my test extension, so this run didn't re-demonstrate the #36novm→ context transition. That code path is unchanged by this PR.Per CONTRIBUTING: I used Claude while writing this, and kept it out of the commit trailers.