Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [chat] Add Chat read state APIs #5268

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/google-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/
| Chat_service.get_membership | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_membership.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.get_membership.js,packages/google-chat/samples/README.md) |
| Chat_service.get_message | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_message.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.get_message.js,packages/google-chat/samples/README.md) |
| Chat_service.get_space | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_space.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.get_space.js,packages/google-chat/samples/README.md) |
| Chat_service.get_space_read_state | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_space_read_state.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.get_space_read_state.js,packages/google-chat/samples/README.md) |
| Chat_service.get_thread_read_state | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_thread_read_state.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.get_thread_read_state.js,packages/google-chat/samples/README.md) |
| Chat_service.list_memberships | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.list_memberships.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.list_memberships.js,packages/google-chat/samples/README.md) |
| Chat_service.list_messages | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.list_messages.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.list_messages.js,packages/google-chat/samples/README.md) |
| Chat_service.list_reactions | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.list_reactions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.list_reactions.js,packages/google-chat/samples/README.md) |
Expand All @@ -148,6 +150,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/
| Chat_service.update_membership | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.update_membership.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.update_membership.js,packages/google-chat/samples/README.md) |
| Chat_service.update_message | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.update_message.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.update_message.js,packages/google-chat/samples/README.md) |
| Chat_service.update_space | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.update_space.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.update_space.js,packages/google-chat/samples/README.md) |
| Chat_service.update_space_read_state | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.update_space_read_state.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.update_space_read_state.js,packages/google-chat/samples/README.md) |
| Chat_service.upload_attachment | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.upload_attachment.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/generated/v1/chat_service.upload_attachment.js,packages/google-chat/samples/README.md) |
| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-chat/samples/quickstart.js,packages/google-chat/samples/README.md) |

Expand Down
44 changes: 43 additions & 1 deletion packages/google-chat/protos/google/chat/v1/chat_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import "google/chat/v1/membership.proto";
import "google/chat/v1/message.proto";
import "google/chat/v1/reaction.proto";
import "google/chat/v1/space.proto";
import "google/chat/v1/space_read_state.proto";
import "google/chat/v1/space_setup.proto";
import "google/chat/v1/thread_read_state.proto";
import "google/protobuf/empty.proto";

option csharp_namespace = "Google.Apps.Chat.V1";
Expand Down Expand Up @@ -53,7 +55,9 @@ service ChatService {
"https://www.googleapis.com/auth/chat.messages.readonly,"
"https://www.googleapis.com/auth/chat.spaces,"
"https://www.googleapis.com/auth/chat.spaces.create,"
"https://www.googleapis.com/auth/chat.spaces.readonly";
"https://www.googleapis.com/auth/chat.spaces.readonly,"
"https://www.googleapis.com/auth/chat.users.readstate,"
"https://www.googleapis.com/auth/chat.users.readstate.readonly";

// Creates a message in a Google Chat space. For an example, see [Send a
// message](https://developers.google.com/workspace/chat/create-messages).
Expand Down Expand Up @@ -502,4 +506,42 @@ service ChatService {
};
option (google.api.method_signature) = "name";
}

// Returns details about a user's read state within a space, used to identify
// read and unread messages.
//
// Requires [user
// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
rpc GetSpaceReadState(GetSpaceReadStateRequest) returns (SpaceReadState) {
option (google.api.http) = {
get: "/v1/{name=users/*/spaces/*/spaceReadState}"
};
option (google.api.method_signature) = "name";
}

// Updates a user's read state within a space, used to identify read and
// unread messages.
//
// Requires [user
// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
rpc UpdateSpaceReadState(UpdateSpaceReadStateRequest)
returns (SpaceReadState) {
option (google.api.http) = {
patch: "/v1/{space_read_state.name=users/*/spaces/*/spaceReadState}"
body: "space_read_state"
};
option (google.api.method_signature) = "space_read_state,update_mask";
}

// Returns details about a user's read state within a thread, used to identify
// read and unread messages.
//
// Requires [user
// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
rpc GetThreadReadState(GetThreadReadStateRequest) returns (ThreadReadState) {
option (google.api.http) = {
get: "/v1/{name=users/*/spaces/*/threads/*/threadReadState}"
};
option (google.api.method_signature) = "name";
}
}
112 changes: 112 additions & 0 deletions packages/google-chat/protos/google/chat/v1/space_read_state.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright 2023 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";
import "google/protobuf/timestamp.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 = "SpaceReadStateProto";
option java_package = "com.google.chat.v1";
option php_namespace = "Google\\Apps\\Chat\\V1";
option ruby_package = "Google::Apps::Chat::V1";

// A user's read state within a space, used to identify read and unread
// messages.
message SpaceReadState {
option (google.api.resource) = {
type: "chat.googleapis.com/SpaceReadState"
pattern: "users/{user}/spaces/{space}/spaceReadState"
singular: "spaceReadState"
};

// Resource name of the space read state.
//
// Format: `users/{user}/spaces/{space}/spaceReadState`
string name = 1;

// Optional. The time when the user's space read state was updated. Usually
// this corresponds with either the timestamp of the last read message, or a
// timestamp specified by the user to mark the last read position in a space.
google.protobuf.Timestamp last_read_time = 2
[(google.api.field_behavior) = OPTIONAL];
}

// Request message for GetSpaceReadState API.
message GetSpaceReadStateRequest {
// Required. Resource name of the space read state to retrieve.
//
// Only supports getting read state for the calling user.
//
// To refer to the calling user, set one of the following:
//
// - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
//
// - Their Workspace email address. For example,
// `users/[email protected]/spaces/{space}/spaceReadState`.
//
// - Their user id. For example,
// `users/123456789/spaces/{space}/spaceReadState`.
//
// Format: users/{user}/spaces/{space}/spaceReadState
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "chat.googleapis.com/SpaceReadState"
}
];
}

// Request message for UpdateSpaceReadState API.
message UpdateSpaceReadStateRequest {
// Required. The space read state and fields to update.
//
// Only supports updating read state for the calling user.
//
// To refer to the calling user, set one of the following:
//
// - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
//
// - Their Workspace email address. For example,
// `users/[email protected]/spaces/{space}/spaceReadState`.
//
// - Their user id. For example,
// `users/123456789/spaces/{space}/spaceReadState`.
//
// Format: users/{user}/spaces/{space}/spaceReadState
SpaceReadState space_read_state = 1 [(google.api.field_behavior) = REQUIRED];

// Required. The field paths to update. Currently supported field paths:
//
// - `last_read_time`
//
// When the `last_read_time` is before the latest message create time, the
// space appears as unread in the UI.
//
// To mark the space as read, set `last_read_time` to any value later (larger)
// than the latest message create time. The `last_read_time` is coerced to
// match the latest message create time. Note that the space read state only
// affects the read state of messages that are visible in the space's
// top-level conversation. Replies in threads are unaffected by this
// timestamp, and instead rely on the thread read state.
google.protobuf.FieldMask update_mask = 2
[(google.api.field_behavior) = REQUIRED];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright 2023 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/timestamp.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 = "ThreadReadStateProto";
option java_package = "com.google.chat.v1";
option php_namespace = "Google\\Apps\\Chat\\V1";
option ruby_package = "Google::Apps::Chat::V1";

// A user's read state within a thread, used to identify read and unread
// messages.
message ThreadReadState {
option (google.api.resource) = {
type: "chat.googleapis.com/ThreadReadState"
pattern: "users/{user}/spaces/{space}/threads/{thread}/threadReadState"
singular: "threadReadState"
};

// Resource name of the thread read state.
//
// Format: `users/{user}/spaces/{space}/threads/{thread}/threadReadState`
string name = 1;

// The time when the user's thread read state was updated. Usually this
// corresponds with the timestamp of the last read message in a thread.
google.protobuf.Timestamp last_read_time = 2;
}

// Request message for GetThreadReadStateRequest API.
message GetThreadReadStateRequest {
// Required. Resource name of the thread read state to retrieve.
//
// Only supports getting read state for the calling user.
//
// To refer to the calling user, set one of the following:
//
// - The `me` alias. For example,
// `users/me/spaces/{space}/threads/{thread}/threadReadState`.
//
// - Their Workspace email address. For example,
// `users/[email protected]/spaces/{space}/threads/{thread}/threadReadState`.
//
// - Their user id. For example,
// `users/123456789/spaces/{space}/threads/{thread}/threadReadState`.
//
// Format: users/{user}/spaces/{space}/threads/{thread}/threadReadState
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "chat.googleapis.com/ThreadReadState"
}
];
}
Loading
Loading