syntax = "proto3";

package devvit.plugin.redditapi.users;

import "devvit/reddit/user.proto";
import "google/protobuf/wrappers.proto";

option go_package = "github.snooguts.net/reddit/reddit-devplatform-monorepo/go-common/generated/protos/types/devvit/plugin/redditapi";
option java_package = "com.reddit.devvit.plugin.redditapi.users";

// Requests
message GenericUsersRequest {
  // thing id e.g. 't3_15bfi0'
  google.protobuf.StringValue id = 1;

  // a valid, existing reddit username
  string username = 2;
}

message BlockUserRequest {
  // account thing id e.g. 't3_15bfi0'
  google.protobuf.StringValue account_id = 1;

  // a valid, existing reddit username
  google.protobuf.StringValue name = 2;
}

message FriendRequest {
  // thing id e.g. 't3_15bfi0'
  google.protobuf.StringValue ban_context = 1;

  // raw markdown text
  google.protobuf.StringValue ban_message = 2;

  // 	a string no longer than 100 characters
  google.protobuf.StringValue ban_reason = 3;

  // an integer between 1 and 999
  google.protobuf.Int32Value duration = 4;

  // the name of an existing user
  string name = 5;

  // a string no longer than 300 characters
  google.protobuf.StringValue note = 6;

  google.protobuf.StringValue permissions = 7;

  // one of (friend, moderator, moderator_invite, contributor, banned, muted, wikibanned, wikicontributor)
  string type = 8;

  // subreddit name without the r/ e.g. 'devvit_test'
  google.protobuf.StringValue subreddit = 9;
}

message ReportUserRequest {
  // JSON data
  string details = 1;

  // 	a string no longer than 100 characters
  string reason = 2;

  // a valid, existing reddit username
  string user = 3;
}

message SetPermissionsRequest {
  // the name of an existing user
  string name = 1;

  // subreddit name without the r/ e.g. 'devvit_test'
  string subreddit = 2;

  string permissions = 3;

  string type = 4;
}

message UnfriendRequest {
  // thing id e.g. 't3_15bfi0'
  google.protobuf.StringValue id = 1;

  // the name of an existing
  google.protobuf.StringValue name = 2;

  // 	one of (friend, enemy, moderator, moderator_invite, contributor, banned, muted, wikibanned, wikicontributor)
  string type = 3;

  // subreddit name without the r/ e.g. 'devvit_test'
  google.protobuf.StringValue subreddit = 4;
}

message UserDataByAccountIdsRequest {
  // a comma-separated list of account thing ids
  string ids = 1;
}

message UsernameAvailableRequest {
  // a valid, unused username
  string user = 1;
}

message UpdateFriendRelationshipRequest {
  // a valid, existing reddit username
  string name = 1;

  string note = 2;
}

message UserAboutRequest {
  // a valid, existing reddit username
  string username = 1;
}

message UserWhereRequest {
  google.protobuf.Int32Value context = 1;
  google.protobuf.StringValue show = 2;
  google.protobuf.StringValue sort = 3;
  google.protobuf.StringValue t = 4;
  google.protobuf.StringValue type = 5;
  google.protobuf.StringValue after = 6;
  google.protobuf.StringValue before = 7;
  google.protobuf.Int64Value count = 8;
  google.protobuf.Int32Value limit = 9;
  google.protobuf.StringValue username = 11;
  string where = 12;
}

// Responses
message GeneralFriendResponse {
  google.protobuf.Int64Value date = 1;
  google.protobuf.StringValue rel_id = 2;
  google.protobuf.StringValue name = 3;
  google.protobuf.StringValue id = 4;

  // error case
  repeated google.protobuf.StringValue fields = 5;
  google.protobuf.StringValue explanation = 6;
  google.protobuf.StringValue message = 7;
  google.protobuf.StringValue reason = 8;
}

message BlockUserResponse {
  google.protobuf.Int64Value date = 1;
  google.protobuf.StringValue icon_img = 2;
  google.protobuf.StringValue id = 3;
  google.protobuf.StringValue name = 4;
}

message UserDataByAccountIdsResponse {
  message UserAccountData {
    google.protobuf.StringValue name = 1;
    google.protobuf.Int64Value created_utc = 2;
    google.protobuf.Int64Value link_karma = 3;
    google.protobuf.Int64Value comment_karma = 4;
    google.protobuf.StringValue profile_img = 5;
    google.protobuf.StringValue profile_color = 6;
    google.protobuf.BoolValue profile_over_18 = 7;
  }

  map<string, UserAccountData> users = 1;
}

message UserTrophiesResponse {
  message TrophiesData {
    google.protobuf.StringValue icon_70 = 1;
    google.protobuf.Int64Value granted_at = 2;
    google.protobuf.StringValue url = 3;
    google.protobuf.StringValue icon_40 = 4;
    google.protobuf.StringValue name = 5;
    google.protobuf.StringValue award_id = 6;
    google.protobuf.StringValue id = 7;
    google.protobuf.StringValue description = 8;
  }

  message TrophiesType {
    google.protobuf.StringValue kind = 1;
    TrophiesData data = 2;
  }

  message UserTrophiesData {
    repeated TrophiesType trophies = 1;
  }

  google.protobuf.StringValue kind = 1;
  UserTrophiesData data = 2;
}

message UserAboutResponse {
  google.protobuf.StringValue kind = 1;
  devvit.reddit.User data = 2;
}

message GetUserKarmaForSubredditRequest {
  // A reddit username (without the u/ prefix), eg 'spez'
  string username = 1;
  // A subreddit ID (t5_), eg 't5_evua8s'
  string subreddit_id = 2;
}

message GetUserKarmaForSubredditResponse {
  // The karma the user has from comments in the subreddit
  google.protobuf.Int64Value from_comments = 1;
  // The karma the user has from posts in the subreddit
  google.protobuf.Int64Value from_posts = 2;
}
