Maps UserNotification object to legacy GRRUser.Notify arguments.

def _MapLegacyArgs(nt, message, ref):
  """Maps UserNotification object to legacy GRRUser.Notify arguments."""
  unt = rdf_objects.UserNotification.Type

  if nt == unt.TYPE_CLIENT_INTERROGATED:
    return [
        "Discovery",
        aff4.ROOT_URN.Add(ref.client.client_id),
        _HostPrefix(ref.client.client_id) + message,
        "",
    ]
  elif nt == unt.TYPE_CLIENT_APPROVAL_REQUESTED:
    return [
        "GrantAccess",
        aff4.ROOT_URN.Add("ACL").Add(ref.approval_request.subject_id).Add(
            ref.approval_request.requestor_username).Add(
                ref.approval_request.approval_id),
        message,
        "",
    ]
  elif nt == unt.TYPE_HUNT_APPROVAL_REQUESTED:
    return [
        "GrantAccess",
        aff4.ROOT_URN.Add("ACL").Add("hunts").Add(
            ref.approval_request.subject_id).Add(
                ref.approval_request.requestor_username).Add(
                    ref.approval_request.approval_id),
        message,
        "",
    ]
  elif nt == unt.TYPE_CRON_JOB_APPROVAL_REQUESTED:
    return [
        "GrantAccess",
        aff4.ROOT_URN.Add("ACL").Add("cron").Add(
            ref.approval_request.subject_id).Add(
                ref.approval_request.requestor_username).Add(
                    ref.approval_request.approval_id),
        message,
        "",
    ]
  elif nt == unt.TYPE_CLIENT_APPROVAL_GRANTED:
    return [
        "ViewObject",
        aff4.ROOT_URN.Add(ref.client.client_id),
        message,
        "",
    ]
  elif nt == unt.TYPE_HUNT_APPROVAL_GRANTED:
    return [
        "ViewObject",
        aff4.ROOT_URN.Add("hunts").Add(ref.hunt.hunt_id),
        message,
        "",
    ]
  elif nt == unt.TYPE_CRON_JOB_APPROVAL_GRANTED:
    return [
        "ViewObject",
        aff4.ROOT_URN.Add("cron").Add(ref.cron_job.cron_job_id),
        message,
        "",
    ]
  elif nt == unt.TYPE_VFS_FILE_COLLECTED:
    return [
        "ViewObject",
        ref.vfs_file.ToURN(),
        _HostPrefix(ref.vfs_file.client_id) + message,
        "",
    ]
  elif nt == unt.TYPE_VFS_FILE_COLLECTION_FAILED:
    return [
        "ViewObject",
        ref.vfs_file.ToURN(),
        _HostPrefix(ref.vfs_file.client_id) + message,
        "",
    ]
  elif nt == unt.TYPE_HUNT_STOPPED:
    urn = aff4.ROOT_URN.Add("hunts").Add(ref.hunt.hunt_id)
    return [
        "ViewObject",
        urn,
        message,
        urn,
    ]
  elif nt == unt.TYPE_FILE_ARCHIVE_GENERATED:
    return [
        "ArchiveGenerationFinished",
        None,
        message,
        "",
    ]
  elif nt == unt.TYPE_FILE_ARCHIVE_GENERATION_FAILED:
    return [
        "Error",
        None,
        message,
        "",
    ]
  elif nt == unt.TYPE_FLOW_RUN_COMPLETED:
    urn = None
    if ref.flow and ref.flow.client_id and ref.flow.flow_id:
      urn = aff4.ROOT_URN.Add(ref.flow.client_id).Add("flows").Add(
          ref.flow.flow_id)
    return [
        "ViewObject",
        urn,
        _HostPrefix(ref.flow.client_id) + message,
        "",
    ]
  elif nt == unt.TYPE_FLOW_RUN_FAILED:
    client_id = None
    urn = None
    prefix = ""
    if ref.flow is not None:
      client_id = ref.flow.client_id

      if client_id:
        prefix = _HostPrefix(client_id)

        if ref.flow.flow_id:
          urn = aff4.ROOT_URN.Add(ref.flow.client_id).Add("flows").Add(
              ref.flow.flow_id)

    return [
        "FlowStatus",
        client_id,
        prefix + message,
        urn,
    ]
  elif nt == unt.TYPE_VFS_LIST_DIRECTORY_COMPLETED:
    return [
        "ViewObject",
        ref.vfs_file.ToURN(),
        message,
        "",
    ]
  elif nt == unt.TYPE_VFS_RECURSIVE_LIST_DIRECTORY_COMPLETED:
    return [
        "ViewObject",
        ref.vfs_file.ToURN(),
        message,
        "",
    ]
  else:
    raise NotImplementedError()