// Copyright 2009 Google Inc. All Rights Reserved.
// Author: morgwai@google.com (Morgwai Kotarbinski)
//
// Messages containing configuration of Feedback Service
// that control classification and processing of submitted feedbacks.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package userfeedback;

// Product for which feedback can be sent: GMail, Writely etc.
message Product {
  required int32 id = 1;

  required string name = 2;

  repeated string owner = 3;
};

// Contains information needed to check whether particular
// feedback type applies to the page user is browsing and forward
// it's execution to a specific handler. It also carries information
// about the creator.
// TODO(morgwai): design new structure of Type with fields relevant
// for android, web, selenium grouped into submessages.
message FeedbackTypeData {
  // index of feedback type as found in database
  required int32 id = 1;

  // Specifies whether this feedback type is currently enabled and
  // feedback of this type can be submitted.
  required bool enabled = 2;

  // Problem name of this feedback type on Google Feedback pages.
  required string problem_name = 3;

  // Name of the product to which this feedback type belongs.
  optional string product_name = 4;

  // Tag 5 is used by some legacy data that is already in production db.

  // matcher to execute against page
  required MatcherData matcher = 6;

  // Comma separated list of email addresses to which email notification
  // is sent upon each new feedback of this type.
  // No email is sent if this field is set to an empty string.
  required string notification_email = 7;

  // Do not use tag 8, 9, 10. They were used by a legacy field.

  // Encapsulates different kind of feedback type.
  enum Kind {
    // Product feedback type.
    PRODUCT = 1;
    // Special feedback type (e.g. fixit).
    SPECIAL = 2;
  }

  // Kind of feedback type.
  optional Kind kind = 11 [default=PRODUCT];

  // Prefix to be added to summary of notification email sent for feedback of this
  // type.
  optional string summary_prefix = 12;

  // String template with which "Additional Info" field in extension
  // should be initially filled.
  optional string template = 13;

  // ID of the product this feedback type belongs to.
  optional int32 product_id = 14;

  // Tag that is used for marking feedback types that require non-ordinary handling.
  // E.g: This field is equal:
  // "unclassified" for Unclassified feedback,
  // "android" for android feedback
  // "selenium" for selenium feedback
  optional string tag = 15;

  // Problem description visible in feedback extension.
  optional string problem_description = 16;

  // Visibilities of feedback type.
  enum Visibility {
    // feedback type visible in external extension only
    EXTERNAL = 1;
    // feedback type visible in internal extension only
    INTERNAL = 2;
  }

  // Specifies the visibility of this feedback type.
  optional Visibility visibility = 17 [default=INTERNAL];

  // tag 18 was used by removed field

  // Specifies Buganizer fields
  // TODO(kaczmarek): enable once we migrated to new protos.
  // optional BuganizerSettings buganizer_settings = 19;

  // Channel via which notification about feedback should be send
  enum NotifyChannel {
    // Send email notification.
    EMAIL = 1;
    // File a bug in buganizer.
    BUGANIZER = 2;
    // File a bug in issue tracker.
    ISSUE_TRACKER = 3;
  }

  // Specifies channel via which notification about feedback of this type should be sent.
  optional NotifyChannel notify_channel = 20 [default=EMAIL];

  // Granularity of notifications.
  enum NotificationGranularity {
    // Send notification per each feedback.
    FEEDBACK = 1;
    // Send notification per clustered group of similar feedbacks.
    CLUSTER = 2;
  }

  // Specifies granularity of notifications send for feedbacks of this type.
  optional NotificationGranularity notification_granularity = 21 [default=FEEDBACK];

  // Threshold for number of feedbacks in a cluster at which notification is sent.
  optional int32 clustering_threshold = 22 [default=5];
};

// Used to detect content relevant to particular type of feedback.
message MatcherData {
  // XPATH expression to match against page.
  required string content_matcher = 1;

  // Regexp matching page URL.
  required string url_matcher = 2;

  // Approval by feedback admins
  optional bool url_matcher_approved = 3 [default=true];
};