function queueBugChange()

in js/details.js [701:789]


function queueBugChange(type, bugId, comment, to) {
  // change types:
  //  clear-flag        - valid params: none
  //  redirect-flag     - valid params: comment
  //  redirect-flag-to  - valid params: comment, to

  let data = null;
  let bug = getBugRec(bugId);
  if (bug == null) {
    console.log("Bug id not found in dataset! Something went wrong.");
    return;
  }

  // Testing UI progress meter for multiple bug changes
  if (ChangeListTest) {
    setTimeout(function () {
      updateAfterChanges(bugId);
    }, TestDelay);
    TestDelay += 500;
    return;
  }

  // https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#update-bug
  if (type == 'clear-flag') {
    data = {
      'flags': [{
        'id': bug.flagid,
        'status': 'X'
      }]
    };
    if (comment != null) {
      data.comment = {
        'body': comment
      };
    }
  } else if (type == 'redirect-flag') {
    // redirect to setter with a comment
    data = {
      'flags': [{
        'id': bug.flagid,
        'status': 'X'
      },
      {
        'name': 'needinfo',
        'status': '?',
        'requestee': bug.nisetter,
        'new': true,
        'type_id': 800
      }]
    };
    if (comment != null) {
      data.comment = {
        'body': comment
      };
    }
  } else if (type == 'redirect-flag-to') {
    // redirect to with a comment
    data = {
      'flags': [{
        'id': bug.flagid,
        'status': 'X'
      },
      {
        'name': 'needinfo',
        'status': '?',
        // doesn't work with aliases?
        'requestee': to,
        'new': true,
        'type_id': 800
      }]
    };
    if (comment != null) {
      data.comment = {
        'body': comment
      };
    }
  } else {
    console.log("unsupported action.")
    return;
  }

  let json = JSON.stringify(data);
  let url = NeedInfoConfig.bugzilla_put_url.replace('{id}', bug.bugid);
  if (NeedInfoConfig.api_key.length) {
    url += "?api_key=" + NeedInfoConfig.api_key;
  }

  submitCommand(url, bugId, json);
}