syntax = "proto3";

package creator_goal;

option go_package = "creator_goal";

import "creator_goal/create.proto";
import "eventbus/change.proto";
import "eventbus/owner.proto";
import "google/protobuf/timestamp.proto";

// CreatorGoalUpdate is triggered when a goal is progressed or ended.
message CreatorGoalUpdate {
  option (eventbus.owner.ldap_group) = "team-creator-supers";
  // The id of the goal.
  string id = 1;
  // The user id of the broadcaster who owns the goal.
  string user_id = 2;
  // The type of goal being updated.
  GoalTypeChange type = 3;
  // The description of the goal.
  eventbus.change.StringChange description = 4;
  // The current point progress towards the target.
  eventbus.change.Int64Change current_amount = 5;
  // The target amount of contributions at which the goal will be completed.
  eventbus.change.Int64Change target_amount = 6;
  // Whether or not the goal has been achieved.
  eventbus.change.BoolChange is_achieved = 7;
  // The timestamp of when the goal was started.
  google.protobuf.Timestamp started_at = 8;
  // The timestamp of when the goal ended. Nil if the goal has not ended.
  google.protobuf.Timestamp ended_at = 9;
}

// GoalTypeChange represents the state change for a goal.
message GoalTypeChange {
  bool updated = 1;
  GoalType value = 2;
  bool has_old_value = 3;
  GoalType old_value = 4;
}
