syntax = "proto3";

package memos.store;

option go_package = "gen/store";

enum InstanceSettingKey {
  INSTANCE_SETTING_KEY_UNSPECIFIED = 0;
  // BASIC is the key for basic settings.
  BASIC = 1;
  // GENERAL is the key for general settings.
  GENERAL = 2;
  // STORAGE is the key for storage settings.
  STORAGE = 3;
  // MEMO_RELATED is the key for memo related settings.
  MEMO_RELATED = 4;
}

message InstanceSetting {
  InstanceSettingKey key = 1;
  oneof value {
    InstanceBasicSetting basic_setting = 2;
    InstanceGeneralSetting general_setting = 3;
    InstanceStorageSetting storage_setting = 4;
    InstanceMemoRelatedSetting memo_related_setting = 5;
  }
}

message InstanceBasicSetting {
  // The secret key for instance. Mainly used for session management.
  string secret_key = 1;
  // The current schema version of database.
  string schema_version = 2;
}

message InstanceGeneralSetting {
  // disallow_user_registration disallows user registration.
  bool disallow_user_registration = 2;
  // disallow_password_auth disallows password authentication.
  bool disallow_password_auth = 3;
  // additional_script is the additional script.
  string additional_script = 4;
  // additional_style is the additional style.
  string additional_style = 5;
  // custom_profile is the custom profile.
  InstanceCustomProfile custom_profile = 6;
  // week_start_day_offset is the week start day offset from Sunday.
  // 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
  // Default is Sunday.
  int32 week_start_day_offset = 7;
  // disallow_change_username disallows changing username.
  bool disallow_change_username = 8;
  // disallow_change_nickname disallows changing nickname.
  bool disallow_change_nickname = 9;
}

message InstanceCustomProfile {
  string title = 1;
  string description = 2;
  string logo_url = 3;
}

message InstanceStorageSetting {
  enum StorageType {
    STORAGE_TYPE_UNSPECIFIED = 0;
    // STORAGE_TYPE_DATABASE is the database storage type.
    DATABASE = 1;
    // STORAGE_TYPE_LOCAL is the local storage type.
    LOCAL = 2;
    // STORAGE_TYPE_S3 is the S3 storage type.
    S3 = 3;
  }
  // storage_type is the storage type.
  StorageType storage_type = 1;
  // The template of file path.
  // e.g. assets/{timestamp}_{filename}
  string filepath_template = 2;
  // The max upload size in megabytes.
  int64 upload_size_limit_mb = 3;
  // The S3 config.
  StorageS3Config s3_config = 4;
}

// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
message StorageS3Config {
  string access_key_id = 1;
  string access_key_secret = 2;
  string endpoint = 3;
  string region = 4;
  string bucket = 5;
  bool use_path_style = 6;
}

message InstanceMemoRelatedSetting {
  // disallow_public_visibility disallows set memo as public visibility.
  bool disallow_public_visibility = 1;
  // display_with_update_time orders and displays memo with update time.
  bool display_with_update_time = 2;
  // content_length_limit is the limit of content length. Unit is byte.
  int32 content_length_limit = 3;
  // enable_double_click_edit enables editing on double click.
  bool enable_double_click_edit = 4;
  // reactions is the list of reactions.
  repeated string reactions = 7;
}
