async def is_pull_request(context, task):
    """Determine if a task is a pull-request-like task (restricted privs).

    This goes further than checking ``tasks_for``. We may or may not want
    to keep this.

    This checks for the following things::

        * ``task.extra.env.tasks_for`` == "github-pull-request"
        * ``task.payload.env.MOBILE_HEAD_REPOSITORY`` doesn't come from an official repo
        * ``task.metadata.source`` doesn't come from an official repo, either
        * The last 2 items are landed on the official repo

    Args:
        context (scriptworker.context.Context): the scriptworker context.
        task (dict): the task definition to check.

    Returns:
        bool: True if it's a pull-request. False if it either comes from the official repos or if
        the origin can't be determined. In fact, valid scriptworker tasks don't expose
        ``task.extra.env.tasks_for`` or ``task.payload.env.MOBILE_HEAD_REPOSITORY``, for instance.

    """
    tasks_for = task.get('extra', {}).get('tasks_for')
    repo_url_from_payload = get_repo(task, context.config['source_env_prefix'])
    revision_from_payload = get_revision(task, context.config['source_env_prefix'])

    metadata_source_url = task['metadata'].get('source', '')
    repo_from_source_url, revision_from_source_url = \
        extract_github_repo_and_revision_from_source_url(metadata_source_url)

    conditions = [tasks_for == 'github-pull-request']
    urls_revisions_and_can_skip = (
        (repo_url_from_payload, revision_from_payload, True),
        (repo_from_source_url, revision_from_source_url, False),
    )
    for repo_url, revision, can_skip in urls_revisions_and_can_skip:
        # XXX In the case of scriptworker tasks, neither the repo nor the revision is defined
        if not repo_url and can_skip:
            continue

        repo_owner, repo_name = extract_github_repo_owner_and_name(repo_url)
        conditions.append(not is_github_repo_owner_the_official_one(context, repo_owner))

        if not revision and can_skip:
            continue

        github_repository = GitHubRepository(repo_owner, repo_name, context.config['github_oauth_token'])
        conditions.append(not await github_repository.has_commit_landed_on_repository(context, revision))

    return any(conditions)
Determine if a task is a pull-request-like task (restricted privs).

    This goes further than checking ``tasks_for``. We may or may not want
    to keep this.

    This checks for the following things::

        * ``task.extra.env.tasks_for`` == "github-pull-request"
        * ``task.payload.env.MOBILE_HEAD_REPOSITORY`` doesn't come from an official repo
        * ``task.metadata.source`` doesn't come from an official repo, either
        * The last 2 items are landed on the official repo

    Args:
        context (scriptworker.context.Context): the scriptworker context.
        task (dict): the task definition to check.

    Returns:
        bool: True if it's a pull-request. False if it either comes from the official repos or if
        the origin can't be determined. In fact, valid scriptworker tasks don't expose
        ``task.extra.env.tasks_for`` or ``task.payload.env.MOBILE_HEAD_REPOSITORY``, for instance.