Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve Voicemail Settings During FreePBX Extension Modifications via GQL API #139

Open
wants to merge 1 commit into
base: release/17.0
Choose a base branch
from

Conversation

RomainBerthet
Copy link

Issue

This pull request addresses Issue #581: Voicemail settings are deleted during extension modifications via the FreePBX API.

Problem

When updating extensions through the updateExtension GQL API endpoint, the voicemail folder is inadvertently deleted. This is due to the delDevice and delUser functions being called without conditions to prevent voicemail deletion during an edit operation. This behavior disrupts configurations by forcing administrators to manually recreate voicemail settings for extensions, adding unnecessary complexity and the risk of errors.

Solution

Modifications to Core.class.php
  • Introduced a conditional check in the delDevice method using the $editmode parameter.
  • If $editmode is set to false, the voicemail folder is deleted as part of the deletion process.
  • If $editmode is true, the voicemail folder remains untouched during the update operation.

Updated Code:

if (!$editmode) {
    $spooldir = $this->config->get('ASTSPOOLDIR');
    $account = preg_replace("/\D/", "", $account);
    if (freepbx_trim($account) !== "" && file_exists($spooldir . "/voicemail/device/" . $account)) {
        exec("rm -f " . escapeshellarg($spooldir . "/voicemail/device/" . $account));
    }
}
Changes in updateExtension Mutation (GQL API)
  • Ensured that the $editmode parameter is set to true when calling the delUser function in the updateExtension mutation.
  • This ensures that the voicemail folder is preserved during extension updates.

Updated Code:

$this->freepbx->Core->delUser($input['extension'], true);

Changes Made

  • In Core.class.php:
    • Modified the delDevice method to include a condition based on the $editmode parameter.
  • In GQL/API/Extensions.php:
    • Updated the updateExtension endpoint to call delUser with $editmode explicitly set to true.

Testing

  • Created an extension with voicemail settings.
  • Updated the extension via the API using the updateExtension endpoint.
  • Verified that voicemail folders and settings were retained after the update.
  • Confirmed that the deletion behavior remained intact when extensions were explicitly deleted (e.g., when $editmode was false).

Conclusion

This pull request resolves the issue of voicemail deletion during API-based extension updates by introducing an edit mode parameter and ensuring its correct usage. The fix preserves voicemail settings, aligning with user expectations and improving the reliability of the FreePBX API.

Please let me know if further modifications or clarifications are needed. Thank you for reviewing this merge request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant