syntax = "proto3";

package poll;

option go_package = "poll";

import "eventbus/owner.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

// PollCreate triggers when a new poll is created on a channel.
message PollCreate {
  option (eventbus.owner.ldap_group) = "team-poliwag-prod";
  // The polls unique ID.
  string id = 1;
  // The ID of the user who owns the poll.
  string owned_by_user_id = 2;
  // The title of the poll.
  string title = 3;
  // The settings for the poll.
  PollSettings settings = 4;
  // The choices for the poll.
  repeated Choice choices = 5;
  // The duration the poll will run for.
  google.protobuf.Duration duration = 6;
  // The status of the poll.
  PollStatus status = 7;
  // Timestamp of when the poll was started.
  google.protobuf.Timestamp started_at = 8;
}

// PollSettings contains the information for the settings on the poll.
message PollSettings {
  // BitsVotes controls whether users can use bits for votes.
  message BitsVotes {
    // Whether voting with bits is enabled.
    bool enabled = 1;
    // The cost of bits per vote.
    int64 cost = 2;
  }
  BitsVotes bits_votes = 1;
  // ChannelPointsVotes controls whether users can use channel points for votes.
  message ChannelPointsVotes {
    // Whether boting with channel points is enabled.
    bool enabled = 1;
    // The cost of channel points per vote.
    int64 cost = 2;
  }
  ChannelPointsVotes channel_points_votes = 2;
}

// Choice contains the information for a choice in a poll.
message Choice {
  // The choices unique ID.
  string id = 1;
  // The title of the choice.
  string title = 2;
}

// PollStatus is the different statuses a poll can have.
enum PollStatus {
  POLL_STATUS_INVALID = 0;
  // Poll is ACTIVE and users can vote.
  POLL_STATUS_ACTIVE = 1;
  // Poll ran its entire duration and "naturally" completed. Users cannot vote, but results are publicly visible.
  POLL_STATUS_COMPLETED = 2;
  // Poll was manually terminated by owner before it ran its entire duration. Users cannot vote, but results are publicly visible.
  POLL_STATUS_TERMINATED = 3;
  // Poll is no longer publicly visible to users.
  POLL_STATUS_ARCHIVED = 4;
  // Poll is no longer visible to any user on Twitch.
  POLL_STATUS_MODERATED = 5;
}
