syntax = "proto3";

package devvit.dev_portal.app_publish_request.modmail;

import "devvit/dev_portal/app_publish_request/review/app_publish_request_review.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.snooguts.net/reddit/reddit-devplatform-monorepo/go-common/generated/protos/types/devvit/devportal/apppublishrequest";

enum AppPRModmailConversationMatchType {
  APP_PR_MODMAIL_CONVERSATION_MATCH_TYPE_UNSPECIFIED = 0;
  APP_PR_MODMAIL_CONVERSATION_MATCH_TYPE_LINKED = 1;
  APP_PR_MODMAIL_CONVERSATION_MATCH_TYPE_FALLBACK = 2;
}

message AppPRModmailMessagePreview {
  string author_display_name = 1;
  string body_markdown = 2;
  google.protobuf.Timestamp created_at = 3;
}

message AppPRModmailConversation {
  // Opaque modmail conversation identifier returned by NewModmail APIs.
  // Example: "2gm7x".
  string conversation_id = 1;
  string subject = 2;
  google.protobuf.Timestamp last_message_created_at = 3;
  // Markdown body of the most recent non-empty message in the conversation.
  string last_message_markdown = 4;
  AppPRModmailConversationMatchType match_type = 5;
  // Most recent non-empty messages, newest first.
  repeated AppPRModmailMessagePreview message_previews = 6;
}

message AppPRListModmailConversationsRequest {
  string app_publish_request_id = 1;

  // Hint for maximum conversations to return.
  // A value of 0 is treated as unspecified; server applies defaults and clamping.
  int32 max_conversations = 2;
  // Hint for maximum preview messages per conversation.
  // A value of 0 is treated as unspecified; server applies defaults and clamping.
  int32 max_message_previews_per_conversation = 3;

  // If false, only linked conversations are returned.
  // If omitted, the server defaults this behavior to true.
  bool include_fallback_matches = 4;
}

message AppPRListModmailConversationsResponse {
  repeated AppPRModmailConversation conversations = 1;
}

message AppPRSetReviewDecisionWithModmailRequest {
  string app_publish_request_id = 1;

  // The server accepts APPROVED and DENIED.
  // Any other enum value is rejected.
  devvit.dev_portal.app_publish_request.review.AppPublishRequestReviewDecision decision = 2;

  string subject = 3;
  string body_markdown = 4;
  // If true, the message is sent as the mod team account.
  // If false, message authoring follows the caller context.
  bool send_as_mod_team = 5;
}

message AppPRSetReviewDecisionWithModmailResponse {
  string modmail_conversation_id = 1;
  bool note_added = 2;
}
