syntax = "proto3";

package devvit.plugin.redditapi.linksandcomments;

import "devvit/plugin/redditapi/common/common_msg.proto";
import "devvit/reddit/comment.proto";
import "devvit/ui/effects/web_view/v1alpha/context.proto";
import "google/protobuf/any.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";
import "reddit/devvit/post/v1/post.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.linksandcomments";

// Request Types
message CommentRequest {
  // Rich-text body of the comment. Serialized RTJSON string.
  // Note: If `richtext_json` is provided, `text` is ignored.
  // @example '{"document":[{"e":"par","c":[{"e":"text","t":"Hello, world!","f":[[2, 0, 13]]}]}]}'
  google.protobuf.StringValue richtext_json = 1;
  // Markdown body of the comment
  // @example '_Hello, world!_'
  string text = 2;
  // Post or Comment thing ID
  // @example "t3_abc123"
  string thing_id = 3;
  // Indicates who the Comment should be created as
  plugin.redditapi.common.RunAs run_as = 4;
}

message FollowPostRequest {
  // `true` to follow; `false` to unfollow
  bool follow = 1;
  // Post thing ID
  // @example "t3_abc123"
  string fullname = 2;
}

message BasicIdRequest {
  // Thing ID
  // @example "t1_abc123"
  string id = 1;
}

message InfoRequest {
  // List of zero or more Subreddit names to fetch
  // @example ["AskReddit", "jokes"]
  repeated string subreddits = 1;
  // List of zero or more thing IDs to fetch
  // Note: Must be a Comment (t1), Post (t3), or Subreddit (t5) ID
  // @example ["t1_abc123", "t3_abc123", "t5_abc123"]
  repeated string thing_ids = 2;
  // Any Link Posts that refer to this URL
  // Note: Providing `url` overrides `subreddits` and `thing_ids`
  // @example "https://www.reddit.com/"
  google.protobuf.StringValue url = 3;
}

message MoreChildrenRequest {
  // List of Comment thing IDs without their "t1_" prefixes
  // @example ["foo123", "bar456", "baz789"]
  repeated string children = 1;
  // Maximum comment depth
  google.protobuf.Int32Value depth = 2;
  // Only return the comments explicitly listed in `children`, otherwise return as many as available
  google.protobuf.BoolValue limit_children = 4;
  // Post thing ID
  // @example "t3_abc123"
  string link_id = 5;
  // Optional, one of: "confidence", "top", "new", "controversial", "old", "random", "qa", "live"
  google.protobuf.StringValue sort = 6;

  // Optional, id of the associated MoreChildren object
  google.protobuf.StringValue id = 7;
}

message ReportRequest {
  // Additional information attached to the report
  google.protobuf.StringValue additional_info = 1;
  // Additional information attached to the report
  google.protobuf.StringValue custom_text = 2;
  // Modmail conversation ID to attach to the report for context
  google.protobuf.StringValue modmail_conv_id = 5;
  // Free-form reason explaining this report
  // Note: If reporting Subreddit content the subreddit must have
  //       "allow free-form reports by users" enabled
  // @see {@link Subreddits.SubredditAboutRules}
  google.protobuf.StringValue other_reason = 6;
  // One of: "rule", "site_reason_selected", "other"
  string reason = 7;
  // The Subreddit rule this thing is violating
  google.protobuf.StringValue rule_reason = 8;
  // The Reddit rule this thing is violating
  google.protobuf.StringValue site_reason = 9;
  // Subreddit name; set if reporting a Post or Comment
  // @example "AskReddit"
  google.protobuf.StringValue sr_name = 10;
  // The thing ID being reported. Must be a Post (t3), Comment (t1), or Private Message (t4)
  // @example "t3_abc123"
  string thing_id = 11;
  // List of comma-separated usernames to associate with this report
  // @example "user1,user2,user3"
  google.protobuf.StringValue usernames = 12;
}

message ReportAwardRequest {
  // Award ID from a Post or Comment
  // @example "award_813b473a-4d74-4933-ba79-a7f1b8b285ef"
  string award_id = 1;
  // Reason for this report
  google.protobuf.StringValue reason = 2;
}

message SaveRequest {
  // Post or Comment thing ID
  // @example "t1_abc123"
  string id = 1;
}

message SendRepliesRequest {
  // Post or Comment thing ID
  // @example "t1_abc123"
  string id = 1;
  // Boolean to enable reply notifications
  bool state = 2;
}

message SetContestModeRequest {
  // Post thing ID
  // @example "t3_abc123"
  string id = 1;
  // Boolean to enable Contest Mode
  bool state = 2;
}

message SetSubredditStickyRequest {
  // Post thing ID
  // @example "t3_abc123"
  string id = 1;
  // Which sticky "slot" this Post should take
  // If the slot is empty or `num` is not set the bottom-most slot will be used
  // Valid range for subreddits: 1 - 2
  // Valid range for user profiles: 1 - 4
  google.protobuf.Int32Value num = 2;
  // Boolean to set the Post as sticky/pinned
  bool state = 3;
  // If the Post is owned by the current user set to `true` to pin
  // it to their profile instead of the subreddit it was posted in
  google.protobuf.BoolValue to_profile = 4;
}

message SetSuggestedSortRequest {
  // Post thing ID
  // @example "t3_abc123"
  string id = 1;
  // One of: "confidence", "top", "new", "controversial", "old", "random", "qa", "live", ""
  // Note: If left blank the suggested sort order is cleared
  string sort = 2;
}

message SubmitRequest {
  // UUID of the collection to add this Post to
  // @example "813b473a-4d74-4933-ba79-a7f1b8b285ef"
  google.protobuf.StringValue collection_id = 2;
  // Flair template ID to use for this Post
  // @example "813b473a-4d74-4933-ba79-a7f1b8b285ef"
  google.protobuf.StringValue flair_id = 7;
  // Custom text to use in the selected flair template if the template
  // has `text_editable` enabled
  google.protobuf.StringValue flair_text = 8;
  // What kind of Post is being created
  // One of: "link", "self", "image", "video", "videogif", "crosspost"
  string kind = 9;
  // Boolean to set the Not-Safe-For-Work tag
  google.protobuf.BoolValue nsfw = 10;
  // Rich-text body of the Post. Serialized RTJSON string.
  // Note: Only used if `kind` is set to "self"
  // Note: `text` and `richtext_json` cannot both be set
  // @example '{"document":[{"e":"par","c":[{"e":"text","t":"Hello, world!","f":[[2, 0, 13]]}]}]}'
  google.protobuf.StringValue richtext_json = 12;
  // Boolean to enable notifications when a comment is added
  google.protobuf.BoolValue sendreplies = 13;
  // Boolean to set the Spoiler tag
  google.protobuf.BoolValue spoiler = 14;
  // Subreddit name
  // @example "AskReddit"
  string sr = 15;
  // Markdown body of the Post
  // Note: Only used if `kind` is set to "self"
  // Note: `text` and `richtext_json` cannot both be set
  // @example "_Hello, world!_"
  google.protobuf.StringValue text = 16;
  // Post title
  string title = 17;
  // The URL this Post refers to if this is a Link Post
  // Note: If `kind` is "video", "videogif", or "image" this must be set to
  //       the media URL created when the media was uploaded
  // Note: If `kind` is "self" this is ignored
  google.protobuf.StringValue url = 18;
  // If `kind` is "video" or "videogif" this must be set to the thumbnail URL
  google.protobuf.StringValue video_poster_url = 19;
  // If `kind` is "crosspost" this must be set to the ID of the post being crossposted
  google.protobuf.StringValue crosspost_fullname = 20;
  // Fallback option of a developer platform experience as rich-text
  google.protobuf.StringValue richtext_fallback = 21;
  // If `kind` is "image" this must be set to the images URLs
  google.protobuf.ListValue image_urls = 22;
  // Indicates who the Post should be submitted as
  plugin.redditapi.common.RunAs run_as = 23;
  // The UserGeneratedContent attached to the Post
  plugin.redditapi.common.UserGeneratedContent user_generated_content = 24;
  // DevvitPostData contains all post data set on the custom post, including internal data and developer-provided data.
  // Example: { "devvit": { "splash": { "tagLine": "my tagline" } }, "developerData": { "riddle": "hello world" } }
  devvit.ui.effects.web_view.v1alpha.DevvitPostData post_data = 25;
  // Custom styles for the post, such as background colors and the post size. Only present on custom posts.
  // Example: { "background_color": "#FF0000FF", "height": "TALL" }
  .reddit.devvit.post.v1.CustomPostStyles custom_post_styles = 26;

  // Removed fields
  reserved 11;
  reserved "resubmit";
}

message VoteRequest {
  // One of: -1, 0, 1
  // Where:
  //   1 = Upvote
  //   0 = Cleared
  //  -1 = Downvote
  int32 dir = 1;
  // Post or Comment thing ID
  // @example "t1_abc123"
  string id = 2;
}

message EditCustomPostRequest {
  // Post or Comment thing ID
  // @example "t3_abc123"
  string thing_id = 1;
  // Fallback option of a developer custom experience as rich-text
  optional google.protobuf.StringValue richtext_fallback = 2;
  // DevvitPostData contains all post data set on the custom post, including internal data and developer-provided data.
  // Example: { "devvit": { "splash": { "tagLine": "my tagline" } }, "developerData": { "riddle": "hello world" } }
  optional devvit.ui.effects.web_view.v1alpha.DevvitPostData post_data = 3;
}

message SetCustomPostPreviewRequest {
  // Post or Comment thing ID
  // @example "t3_abc123"
  string thing_id = 1;

  enum BodyType {
    // Default value. Should not be used for requests.
    UNKNOWN = 0;
    // Body is a Blocks rendering, and should be present in `blocks_render_content`.
    BLOCKS = 1;
  }
  BodyType body_type = 2;

  // For body_type=BLOCKS, this is a base64-encoded Block proto.
  // See: devvit.ui.block_kit.v1beta.Block
  google.protobuf.StringValue blocks_render_content = 3;
}

message GetIsPostHighlightedRequest {
  // Post thing ID.
  // @example "t3_abc123"
  string post_id = 1;
}

message AddPostToHighlightsRequest {
  // Post thing ID.
  // @example "t3_abc123"
  string post_id = 1;
  // Expiration time as a Unix timestamp in seconds.
  // If left empty, the post will remain in the highlights until explicitly removed.
  optional int64 expires_at = 2;
  // Label to display for the highlighted post.
  // If left empty, the post will show no label in the community highlights.
  optional devvit.plugin.redditapi.common.HighlightedPostLabel label = 3;
}

message RemovePostFromHighlightsRequest {
  // Post thing ID.
  // @example "t3_abc123"
  string post_id = 1;
}

// Response Types

message GetIsPostHighlightedResponse {
  // Whether the post is highlighted.
  bool is_highlighted = 1;
}

message AddPostToHighlightsResponse {}

message RemovePostFromHighlightsResponse {}

message JsonWrappedComment {
  message WrappedComment {
    string kind = 1;
    devvit.reddit.Comment data = 2;
  }
  message JsonData {
    repeated WrappedComment things = 1;
  }
  message Json {
    repeated string errors = 1;
    JsonData data = 2;
  }
  Json json = 1;
}

message SubmitResponse {
  message JsonType {
    message JsonData {
      google.protobuf.StringValue url = 1;
      google.protobuf.Int32Value drafts_count = 2;
      google.protobuf.StringValue id = 3;
      google.protobuf.StringValue name = 4;
    }

    repeated google.protobuf.Any errors = 1;
    JsonData data = 2;
  }
  JsonType json = 4;
}

message SetCustomPostStylesRequest {
  // Post thing ID
  // @example "t3_abc123"
  string post_id = 5;
  // Custom styles for the post, such as background colors and the post size. Only present on custom posts.
  // If set to `undefined`, all settings will be reset to their default values.
  // Example: { "background_color": "#FF0000FF", "height": "TALL" }
  CustomPostStylesInput custom_post_styles = 2;
}

message GetCustomPostStylesRequest {
  // Post thing ID
  // @example "t3_abc123"
  string post_id = 5;
}

message GetUserPollOptionRequest {
  // Post thing ID
  // @example "t3_1rvjxj7"
  string post_id = 1;
}

message GetUserPollOptionResponse {
  // The poll option selected by the authenticated user.
  devvit.plugin.redditapi.common.PollOption poll_option = 1;
}

// This is a variant of CustomPostStyles that is used for input in the SetCustomPostStylesRequest
// and makes each field optional.
message CustomPostStylesInput {
  // The default background color shown before an iframe is loaded. Must be in #RRGGBBAA (red, green, blue, alpha transparency) format with a leading hash.
  // The value is case-insensitive. Defaults to transparent (#00000000).
  optional string background_color = 1;
  // The dark mode background color shown before an iframe is loaded. Must be in #RRGGBBAA (red, green, blue, alpha transparency) format with a leading hash.
  // The value is case-insensitive. Defaults to transparent (#00000000).
  optional string background_color_dark = 2;
  // The height of the post in pixels. Must be between 72 and 512 inclusive. When set, takes priority
  // over the enum-based height field.
  // @example 320
  optional int32 height_pixels = 3;
  // The height of the post. Defaults to 'tall'. This field is used to create or update the Post height.
  // Devvit Gateway maps 'tall' or 'regular' to the pixel height and returns both 'height_pixels' and 'height' to GQL.
  optional .reddit.devvit.post.v1.EntrypointHeight height = 4;
  // The URL of the preview image to show when being shared (e.x. OpenGraph's `og:image`).
  // Defaults to `https://i.redd.it/o0h58lzmax6a1.png`, which is the generic image used for any page that doesn't have a preview image.
  optional string share_image_url = 5;
}
