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 Advanced Extension Settings in FreePBX GQL API #134

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

Conversation

RomainBerthet
Copy link

Issue

[bug]: Advanced Settings Reset or Omitted During Extension Creation/Modification via GQL API
Original Issue: FreePBX/issue-tracker#528
FreePBX Version: 17.0.19.16
Asterisk Version: 21.4.3

Problem

When creating or modifying extensions via the FreePBX GQL API, advanced settings are often reset to default values or omitted entirely. This issue stems from the GQL API’s method of updating extensions: extensions are deleted and recreated without fully retaining user-specified parameters. Consequently, essential settings (e.g., DTMF Signaling, Transport, Call Waiting, Ring Time) revert to defaults, disrupting configurations that rely on specific, user-defined values.

Solution

To resolve this issue, I enhanced the API’s handling of extension updates by merging all relevant data sources into a unified dataset before calling the update function. This modification ensures that all user-defined advanced settings are retained unless explicitly undefined, aligning the API’s behavior with expected user outcomes.

Changes Made

  1. Modifications in Extensions.php

    • Introduced a new variable $total to combine data from $extensionsExists, $users, and $input. This unified dataset includes the full scope of parameters needed to persist all advanced settings during updates.
    • Updated the call to processQuickCreate() to utilize $total instead of $input, ensuring complete parameter retention.
  2. Enhancements in Core.class.php

    • Added conditional checks for each field provided by generateDefaultUserSettings() to ensure that $settings correctly reflects user-defined values:
      $settings['ringtimer'] = isset($data['ringtimer']) ? $data['ringtimer'] : 0;
    • Applied the same conditional assignment approach to device settings, guaranteeing that user-specified values are prioritized. Example code:
      $settings['trustrpid']['value'] = isset($data['trustrpid']) ? $data['trustrpid'] : "yes";
  3. Expanded Field Set in getMutationFieldsupdate()

    • Adjusted getMutationFieldsupdate() to incorporate additional parameters where necessary. This ensures that essential fields are correctly recognized and updated during API calls. For example:
      'ringtimer' => [
          'type' => Type::string(),
          'description' => _("Ring Time")
      ],
  4. Additions to Default Parameters in generateDefaultUserSettings()

    • Extended generateDefaultUserSettings() to include new parameters, such as dialopts, call_screen, and rvolume, to ensure these fields can be managed and modified via the API. Code added:
      public function generateDefaultUserSettings($number, $displayname) {
          return array(
              ...
              "call_screen" => "0",
              "rvolume" => "",
              "dialopts" => ""
          );
      }

Thank you for reviewing this merge request. Please let me know if further clarification or adjustments are required.

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