// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.chat.v1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Google.Apps.Chat.V1";
option go_package = "cloud.google.com/go/chat/apiv1/chatpb;chatpb";
option java_multiple_files = true;
option java_outer_classname = "SpaceNotificationSettingProto";
option java_package = "com.google.chat.v1";
option objc_class_prefix = "DYNAPIProto";
option php_namespace = "Google\\Apps\\Chat\\V1";
option ruby_package = "Google::Apps::Chat::V1";

// The notification setting of a user in a space.
message SpaceNotificationSetting {
  option (google.api.resource) = {
    type: "chat.googleapis.com/SpaceNotificationSetting"
    pattern: "users/{user}/spaces/{space}/spaceNotificationSetting"
    singular: "spaceNotificationSetting"
  };

  // The notification setting types. Other types might be supported in the
  // future.
  enum NotificationSetting {
    // Reserved.
    NOTIFICATION_SETTING_UNSPECIFIED = 0;

    // Notifications are triggered by @mentions, followed threads, first
    // message of new threads. All new threads are automatically followed,
    // unless manually unfollowed by the user.
    ALL = 1;

    // The notification is triggered by @mentions, followed threads, first
    // message of new threads. Not available for 1:1 direct messages.
    MAIN_CONVERSATIONS = 2;

    // The notification is triggered by @mentions, followed threads. Not
    // available for 1:1 direct messages.
    FOR_YOU = 3;

    // Notification is off.
    OFF = 4;
  }

  // The space notification mute setting types.
  enum MuteSetting {
    // Reserved.
    MUTE_SETTING_UNSPECIFIED = 0;

    // The user will receive notifications for the space based on the
    // notification setting.
    UNMUTED = 1;

    // The user will not receive any notifications for the space, regardless of
    // the notification setting.
    MUTED = 2;
  }

  // Identifier. The resource name of the space notification setting.
  // Format: `users/{user}/spaces/{space}/spaceNotificationSetting`.
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // The notification setting.
  optional NotificationSetting notification_setting = 2;

  // The space notification mute setting.
  optional MuteSetting mute_setting = 3;
}

// Request message to get space notification setting.
// Only supports getting notification setting for the calling user.
message GetSpaceNotificationSettingRequest {
  // Required. Format: users/{user}/spaces/{space}/spaceNotificationSetting
  //
  // - `users/me/spaces/{space}/spaceNotificationSetting`, OR
  // - `users/user@example.com/spaces/{space}/spaceNotificationSetting`, OR
  // - `users/123456789/spaces/{space}/spaceNotificationSetting`.
  // Note: Only the caller's user id or email is allowed in the path.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "chat.googleapis.com/SpaceNotificationSetting"
    }
  ];
}

// Request to update the space notification settings.
// Only supports updating notification setting for the calling user.
message UpdateSpaceNotificationSettingRequest {
  // Required. The resource name for the space notification settings must be
  // populated in the form of
  // `users/{user}/spaces/{space}/spaceNotificationSetting`. Only fields
  // specified by `update_mask` are updated.
  SpaceNotificationSetting space_notification_setting = 1
      [(google.api.field_behavior) = REQUIRED];

  // Required. Supported field paths:
  //
  // - `notification_setting`
  //
  // - `mute_setting`
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = REQUIRED];
}
