@namespace("keybase.1")
protocol user {
  import idl "common.avdl";

  record Tracker {
    UID tracker;
    int status; // 0 == none, 1 == tracking
    Time mTime;
  }

  array<Tracker> listTrackers(int sessionID, UID uid);
  array<Tracker> listTrackersByName(int sessionID, string username);
  array<Tracker> listTrackersSelf(int sessionID);

  record TrackProof {
    string proofType;
    string proofName;
    string idString;
  }

  record WebProof {
    string hostname;
    array<string> protocols;
  }

  record Proofs {
    array<TrackProof> social;
    array<WebProof> web;
    array<PublicKey> publicKeys;
  }

  record UserSummary {
    UID uid;
    string username;
    string thumbnail;
    int idVersion;
    string fullName;
    string bio;
    Proofs proofs;
    string sigIDDisplay;
    Time trackTime;
  }

  record Email {
    string email;
    boolean isVerified;
  }

  record UserSettings {
    array<Email> emails;
  }

  /**
    Load user summaries for the supplied uids.
    They are "unchecked" in that the client is not verifying the info from the server.
    If len(uids) > 500, the first 500 will be returned.
    */
  array<UserSummary> loadUncheckedUserSummaries(int sessionID, array<UID> uids);

  /**
    Load a user from the server.
    */
  User loadUser(int sessionID, UID uid);
  User loadUserByName(int sessionID, string username);

  /**
    Load a user + device keys from the server.
    */
  UserPlusKeys loadUserPlusKeys(int sessionID, UID uid, KID pollForKID);

  /**
    Load public keys for a user.
    */
  array<PublicKey> loadPublicKeys(int sessionID, UID uid);

  /**
    Load my public keys (for logged in user).
    */
  array<PublicKey> loadMyPublicKeys(int sessionID);

  /**
    Load user settings (for logged in user).
    */
  UserSettings loadMySettings(int sessionID);

  /**
    The list-tracking functions get verified data from the tracking statements
    in the user's sigchain.

    If assertion is empty, it will use the current logged in user.
    */
  array<UserSummary> listTracking(int sessionID, string filter, string assertion);
  string listTrackingJSON(int sessionID, string filter, boolean verbose, string assertion);

  record SearchComponent {
    string key;
    string value;
    double score;
  }

  record SearchResult {
    UID uid;
    string username;
    array<SearchComponent> components;
    double score;
  }

  /**
    Search for users who match a given query.
    */
  array<SearchResult> search(int sessionID, string query);

  /**
    Load all the user's public keys (even those in reset key families)
    from the server with no verification
    */
  array<PublicKey> loadAllPublicKeysUnverified(int sessionID, UID uid);

  record UserSummary2 {
    UID uid;
    string username;
    string thumbnail;
    string fullName;
    boolean isFollower;
    boolean isFollowee;
  }

  record UserSummary2Set {
    array<UserSummary2> users;
    Time time;
    int version;
  }

  UserSummary2Set listTrackers2(int sessionID, string assertion, boolean reverse);

  void profileEdit(int sessionID, string fullName, string location, string bio);
}
