syntax = "proto3";

package devvit.platform.v1;

option go_package = "github.snooguts.net/reddit/devplatform-api/go/grpc/devvit/platform/v1";

// RequestContext contains all the contextual information about a request
// This context is signed as a JWT token and passed between services
message RequestContext {
  // Installation information for the app installation
  InstallationContext installation = 1;
  // App information including ID, name, version, and status
  AppContext app = 2;
  // Post information if the request is related to a specific post
  PostContext post = 3;
  // Subreddit information if the request is related to a specific subreddit
  SubredditContext subreddit = 4;
  // User information if the request is made by an authenticated user
  UserContext user = 5;
}

// InstallationContext contains information about the app installation
message InstallationContext {
  // Installation ID in UUID format (e.g., "8b8ae08b-3645-49c7-b425-bd989e09bea3")
  string id = 1;
}

enum AppStatus {
  // Default value. Should not be used for requests.
  APP_STATUS_UNSPECIFIED = 0;
  // App is in prerelease state
  PRERELEASE = 1;
  // App is published and available
  PUBLISHED = 2;
}

// AppContext contains information about the Devvit app
message AppContext {
  // App ID in UUID format (e.g., "550e8400-e29b-41d4-a716-446655440000")
  string id = 1 [deprecated = true];
  // Name of the app (e.g., "My Funky App" (not a slug)
  string name = 2 [deprecated = true];
  // Semantic version number with 4 parts (e.g., "1.2.3.4")
  string version = 3;
  // Current publishing status of the app
  AppStatus status = 4;
  // App unique identifier, also known as the slug (e.g., "my-funky-app")
  string slug = 5;
  // App account information
  AppAccount account = 6;
}

message AppAccount {
  // Account ID (e.g., "t2_15bfi0")
  string id = 1;
}

// PostContext contains information about a Reddit post
message PostContext {
  // Post ID (e.g., "t3_15bfi0")
  string id = 1;
  // Author's account ID (e.g., "t2_1a2b3c4d")
  string author = 2;
}

// SubredditContext contains information about a Reddit subreddit
message SubredditContext {
  // Subreddit name without the r/ (e.g., "testsubreddit123456")
  string name = 1;
  // Subreddit ID (e.g., "t5_1a2b3c")
  string id = 2;
}

// UserContext contains information about a Reddit user
message UserContext {
  // Reddit username, maximum 20 characters (e.g., "spez")
  string name = 1;
  // User's account ID (e.g., "t2_15bfi0")
  string id = 2;
  // Snoovatar image URL with Reddit's preview domain and query parameters
  // (e.g., "https://preview.redd.it/snoovatar/avatars/5e7b8e37-8189-4b33-b001-250bb8bdb730-headshot.png")
  string snoovatar = 3;
}
