validateWriteResponse function

void validateWriteResponse(
  1. JsonMap response
)

Check that YTM performed a write request instead of answering with a dialog. A gated request returns HTTP 200 with only a showEngagementPanelEndpoint action carrying the original request, for the web client to replay once the user has dealt with the dialog.

Implementation

/// A gated request returns HTTP 200 with only a [showEngagementPanelEndpoint] action carrying the
/// original request, for the web client to replay once the user has dealt with the dialog.

/// - throws [YTMusicGatedError]: if the request was not performed
void validateWriteResponse(JsonMap response) {
  final panel = nav(response, [
    'actions',
    0,
    'showEngagementPanelEndpoint',
  ], nullIfAbsent: true);
  if (panel == null) {
    return;
  }
  final tag = nav(panel, ['identifier', 'tag'], nullIfAbsent: true);
  throw YTMusicGatedError(
    'YouTube Music did not perform this request and asked for interaction with its "$tag" dialog. The account may be temporarily restricted from this action.',
  );
}