syntax = "proto3";

package devvit.plugin.notifications;

import "google/protobuf/struct.proto";

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

// Request to queue a push notification for a user
message EnqueueRequest {
  // The title of the push notification (mustache template supported)
  string title = 1;

  // The body text of the push notification (mustache template supported)
  string body = 2;

  // List of recipients to send the notification to
  repeated Recipient recipients = 5;
}

// Response from queuing multiple push notifications
message EnqueueResponse {
  // Number of notifications successfully queued
  int32 success_count = 1;

  // Number of notifications that failed to queue
  int32 failure_count = 2;

  // Array of errors for notifications that failed to queue
  repeated EnqueueError errors = 3;

  // Unix timestamp when the bulk operation was performed
  int64 timestamp = 4;
}

message Recipient {
  // The Reddit user ID to send the notification to (e.g. "t2_abc123")
  string user_id = 1;

  // The thing (comment or post) associated with this notification
  oneof thing {
    // The fullname of a comment (e.g., "t1_abc123")
    string comment = 2;

    // The fullname of a post (e.g., "t3_abc123")
    string post = 3;
  }

  // Additional data to include with the notification's mustache template
  google.protobuf.Struct data = 4;
}

message EnqueueError {
  // The Reddit user ID for which the notification failed to queue (e.g. "t2_abc123")
  string user_id = 1;

  // Error message describing why the notification failed to queue
  string message = 2;
}
