syntax = "proto3";

package devvit.dev_portal.modmail_template;

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

// Whether a template is used for rejection or publication modmail.
enum ModmailTemplateActionType {
  // Unspecified action type.
  MODMAIL_TEMPLATE_ACTION_TYPE_UNSPECIFIED = 0;
  // Template is sent when rejecting an app.
  MODMAIL_TEMPLATE_ACTION_TYPE_REJECT = 1;
  // Template is sent when publishing an app.
  MODMAIL_TEMPLATE_ACTION_TYPE_PUBLISH = 2;
}

// A modmail message template managed by app reviewers.
message ModmailTemplate {
  // The template UUID, for example "a1b2c3d4-5678-90ab-cdef-1234567890ab".
  string id = 1;
  // Short display title, for example "Missing privacy policy".
  string title = 2;
  // The markdown body of the template, for example "Your app is missing a privacy policy link in the description.".
  string body = 3;
  // Whether this template applies to rejection or publication, for example MODMAIL_TEMPLATE_ACTION_TYPE_REJECT.
  ModmailTemplateActionType action_type = 4;
  // Optional group name for grouping related templates, for example "Policy violations".
  string group_name = 5;
  // Zero-based position within the action type list, for example 0.
  int32 sort_order = 6;
}

// Global header/footer configuration applied to all modmail messages.
message ModmailConfig {
  // Markdown prepended to rejection messages, for example "Hi, thank you for submitting your app.".
  string reject_header = 1;
  // Markdown appended to rejection messages, for example "Please feel free to resubmit after addressing the above.".
  string reject_footer = 2;
  // Markdown prepended to publication messages, for example "Congratulations!".
  string publish_header = 3;
  // Markdown appended to publication messages, for example "Your app is now live on the directory.".
  string publish_footer = 4;
}

// Request to list all modmail templates and the global config.
message ListModmailTemplatesRequest {}

// Response containing all templates and global config.
message ListModmailTemplatesResponse {
  // All modmail templates ordered by action type and sort order.
  repeated ModmailTemplate templates = 1;
  // The global header/footer configuration.
  ModmailConfig config = 2;
}

// Request to create a new modmail template.
message CreateModmailTemplateRequest {
  // Short display title, for example "Missing privacy policy".
  string title = 1;
  // Markdown body of the template, for example "Your app must include a privacy policy.".
  string body = 2;
  // Whether this template is for rejection or publication, for example "REJECT".
  string action_type = 3;
  // Optional group name, for example "Policy violations".
  string group_name = 4;
}

// Request to update an existing modmail template.
message UpdateModmailTemplateRequest {
  // The template UUID to update, for example "a1b2c3d4-5678-90ab-cdef-1234567890ab".
  string id = 1;
  // New title, if provided, for example "Updated privacy policy".
  optional string title = 2;
  // New body, if provided.
  optional string body = 3;
  // New action type, if provided, for example "PUBLISH".
  optional string action_type = 4;
  // New group name, if provided, for example "Policy violations".
  optional string group_name = 5;
  // New sort order, if provided, for example 3.
  optional int32 sort_order = 6;
}

// Request to delete a single modmail template.
message DeleteModmailTemplateRequest {
  // The template UUID to delete, for example "a1b2c3d4-5678-90ab-cdef-1234567890ab".
  string id = 1;
}

// Request to dissolve or delete a group of templates.
message DeleteModmailTemplateGroupRequest {
  // The group name to target, for example "Policy violations".
  string group_name = 1;
  // The action type the group belongs to, for example "REJECT".
  string action_type = 2;
  // If true, un-group the templates instead of deleting them.
  bool keep_templates = 3;
}

// Request to reorder templates by specifying the desired ID order.
message ReorderModmailTemplatesRequest {
  // Ordered list of template UUIDs, for example ["id1", "id2", "id3"].
  repeated string template_ids = 1;
}

// Request to retrieve the global modmail config.
message GetModmailConfigRequest {}

// Request to update the global modmail config.
message UpdateModmailConfigRequest {
  // New reject header, if provided, for example "Hi, thank you for submitting your app.".
  optional string reject_header = 1;
  // New reject footer, if provided.
  optional string reject_footer = 2;
  // New publish header, if provided, for example "Congratulations!".
  optional string publish_header = 3;
  // New publish footer, if provided.
  optional string publish_footer = 4;
}
