Skip to content

Commit 3b345ca

Browse files
feat: [chat] Add Chat read state APIs (#5268)
* feat: Add Chat read state APIs PiperOrigin-RevId: 626377569 Source-Link: googleapis/googleapis@e9672e7 Source-Link: googleapis/googleapis-gen@50c8b6a Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNoYXQvLk93bEJvdC55YW1sIiwiaCI6IjUwYzhiNmFmMTZiZWI3YzAzMDZkZmYxMjcxN2FiMmI5NzY2MDU3ZTAifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 02c6ae6 commit 3b345ca

17 files changed

Lines changed: 3649 additions & 134 deletions

packages/google-chat/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/
140140
| 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) |
141141
| 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) |
142142
| 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) |
143+
| 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) |
144+
| 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) |
143145
| 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) |
144146
| 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) |
145147
| 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) |
@@ -148,6 +150,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/
148150
| 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) |
149151
| 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) |
150152
| 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) |
153+
| 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) |
151154
| 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) |
152155
| 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) |
153156

packages/google-chat/protos/google/chat/v1/chat_service.proto

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import "google/chat/v1/membership.proto";
2323
import "google/chat/v1/message.proto";
2424
import "google/chat/v1/reaction.proto";
2525
import "google/chat/v1/space.proto";
26+
import "google/chat/v1/space_read_state.proto";
2627
import "google/chat/v1/space_setup.proto";
28+
import "google/chat/v1/thread_read_state.proto";
2729
import "google/protobuf/empty.proto";
2830

2931
option csharp_namespace = "Google.Apps.Chat.V1";
@@ -53,7 +55,9 @@ service ChatService {
5355
"https://www.googleapis.com/auth/chat.messages.readonly,"
5456
"https://www.googleapis.com/auth/chat.spaces,"
5557
"https://www.googleapis.com/auth/chat.spaces.create,"
56-
"https://www.googleapis.com/auth/chat.spaces.readonly";
58+
"https://www.googleapis.com/auth/chat.spaces.readonly,"
59+
"https://www.googleapis.com/auth/chat.users.readstate,"
60+
"https://www.googleapis.com/auth/chat.users.readstate.readonly";
5761

5862
// Creates a message in a Google Chat space. For an example, see [Send a
5963
// message](https://developers.google.com/workspace/chat/create-messages).
@@ -502,4 +506,42 @@ service ChatService {
502506
};
503507
option (google.api.method_signature) = "name";
504508
}
509+
510+
// Returns details about a user's read state within a space, used to identify
511+
// read and unread messages.
512+
//
513+
// Requires [user
514+
// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
515+
rpc GetSpaceReadState(GetSpaceReadStateRequest) returns (SpaceReadState) {
516+
option (google.api.http) = {
517+
get: "/v1/{name=users/*/spaces/*/spaceReadState}"
518+
};
519+
option (google.api.method_signature) = "name";
520+
}
521+
522+
// Updates a user's read state within a space, used to identify read and
523+
// unread messages.
524+
//
525+
// Requires [user
526+
// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
527+
rpc UpdateSpaceReadState(UpdateSpaceReadStateRequest)
528+
returns (SpaceReadState) {
529+
option (google.api.http) = {
530+
patch: "/v1/{space_read_state.name=users/*/spaces/*/spaceReadState}"
531+
body: "space_read_state"
532+
};
533+
option (google.api.method_signature) = "space_read_state,update_mask";
534+
}
535+
536+
// Returns details about a user's read state within a thread, used to identify
537+
// read and unread messages.
538+
//
539+
// Requires [user
540+
// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
541+
rpc GetThreadReadState(GetThreadReadStateRequest) returns (ThreadReadState) {
542+
option (google.api.http) = {
543+
get: "/v1/{name=users/*/spaces/*/threads/*/threadReadState}"
544+
};
545+
option (google.api.method_signature) = "name";
546+
}
505547
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.chat.v1;
18+
19+
import "google/api/field_behavior.proto";
20+
import "google/api/resource.proto";
21+
import "google/protobuf/field_mask.proto";
22+
import "google/protobuf/timestamp.proto";
23+
24+
option csharp_namespace = "Google.Apps.Chat.V1";
25+
option go_package = "cloud.google.com/go/chat/apiv1/chatpb;chatpb";
26+
option java_multiple_files = true;
27+
option java_outer_classname = "SpaceReadStateProto";
28+
option java_package = "com.google.chat.v1";
29+
option php_namespace = "Google\\Apps\\Chat\\V1";
30+
option ruby_package = "Google::Apps::Chat::V1";
31+
32+
// A user's read state within a space, used to identify read and unread
33+
// messages.
34+
message SpaceReadState {
35+
option (google.api.resource) = {
36+
type: "chat.googleapis.com/SpaceReadState"
37+
pattern: "users/{user}/spaces/{space}/spaceReadState"
38+
singular: "spaceReadState"
39+
};
40+
41+
// Resource name of the space read state.
42+
//
43+
// Format: `users/{user}/spaces/{space}/spaceReadState`
44+
string name = 1;
45+
46+
// Optional. The time when the user's space read state was updated. Usually
47+
// this corresponds with either the timestamp of the last read message, or a
48+
// timestamp specified by the user to mark the last read position in a space.
49+
google.protobuf.Timestamp last_read_time = 2
50+
[(google.api.field_behavior) = OPTIONAL];
51+
}
52+
53+
// Request message for GetSpaceReadState API.
54+
message GetSpaceReadStateRequest {
55+
// Required. Resource name of the space read state to retrieve.
56+
//
57+
// Only supports getting read state for the calling user.
58+
//
59+
// To refer to the calling user, set one of the following:
60+
//
61+
// - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
62+
//
63+
// - Their Workspace email address. For example,
64+
// `users/user@example.com/spaces/{space}/spaceReadState`.
65+
//
66+
// - Their user id. For example,
67+
// `users/123456789/spaces/{space}/spaceReadState`.
68+
//
69+
// Format: users/{user}/spaces/{space}/spaceReadState
70+
string name = 1 [
71+
(google.api.field_behavior) = REQUIRED,
72+
(google.api.resource_reference) = {
73+
type: "chat.googleapis.com/SpaceReadState"
74+
}
75+
];
76+
}
77+
78+
// Request message for UpdateSpaceReadState API.
79+
message UpdateSpaceReadStateRequest {
80+
// Required. The space read state and fields to update.
81+
//
82+
// Only supports updating read state for the calling user.
83+
//
84+
// To refer to the calling user, set one of the following:
85+
//
86+
// - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
87+
//
88+
// - Their Workspace email address. For example,
89+
// `users/user@example.com/spaces/{space}/spaceReadState`.
90+
//
91+
// - Their user id. For example,
92+
// `users/123456789/spaces/{space}/spaceReadState`.
93+
//
94+
// Format: users/{user}/spaces/{space}/spaceReadState
95+
SpaceReadState space_read_state = 1 [(google.api.field_behavior) = REQUIRED];
96+
97+
// Required. The field paths to update. Currently supported field paths:
98+
//
99+
// - `last_read_time`
100+
//
101+
// When the `last_read_time` is before the latest message create time, the
102+
// space appears as unread in the UI.
103+
//
104+
// To mark the space as read, set `last_read_time` to any value later (larger)
105+
// than the latest message create time. The `last_read_time` is coerced to
106+
// match the latest message create time. Note that the space read state only
107+
// affects the read state of messages that are visible in the space's
108+
// top-level conversation. Replies in threads are unaffected by this
109+
// timestamp, and instead rely on the thread read state.
110+
google.protobuf.FieldMask update_mask = 2
111+
[(google.api.field_behavior) = REQUIRED];
112+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.chat.v1;
18+
19+
import "google/api/field_behavior.proto";
20+
import "google/api/resource.proto";
21+
import "google/protobuf/timestamp.proto";
22+
23+
option csharp_namespace = "Google.Apps.Chat.V1";
24+
option go_package = "cloud.google.com/go/chat/apiv1/chatpb;chatpb";
25+
option java_multiple_files = true;
26+
option java_outer_classname = "ThreadReadStateProto";
27+
option java_package = "com.google.chat.v1";
28+
option php_namespace = "Google\\Apps\\Chat\\V1";
29+
option ruby_package = "Google::Apps::Chat::V1";
30+
31+
// A user's read state within a thread, used to identify read and unread
32+
// messages.
33+
message ThreadReadState {
34+
option (google.api.resource) = {
35+
type: "chat.googleapis.com/ThreadReadState"
36+
pattern: "users/{user}/spaces/{space}/threads/{thread}/threadReadState"
37+
singular: "threadReadState"
38+
};
39+
40+
// Resource name of the thread read state.
41+
//
42+
// Format: `users/{user}/spaces/{space}/threads/{thread}/threadReadState`
43+
string name = 1;
44+
45+
// The time when the user's thread read state was updated. Usually this
46+
// corresponds with the timestamp of the last read message in a thread.
47+
google.protobuf.Timestamp last_read_time = 2;
48+
}
49+
50+
// Request message for GetThreadReadStateRequest API.
51+
message GetThreadReadStateRequest {
52+
// Required. Resource name of the thread read state to retrieve.
53+
//
54+
// Only supports getting read state for the calling user.
55+
//
56+
// To refer to the calling user, set one of the following:
57+
//
58+
// - The `me` alias. For example,
59+
// `users/me/spaces/{space}/threads/{thread}/threadReadState`.
60+
//
61+
// - Their Workspace email address. For example,
62+
// `users/user@example.com/spaces/{space}/threads/{thread}/threadReadState`.
63+
//
64+
// - Their user id. For example,
65+
// `users/123456789/spaces/{space}/threads/{thread}/threadReadState`.
66+
//
67+
// Format: users/{user}/spaces/{space}/threads/{thread}/threadReadState
68+
string name = 1 [
69+
(google.api.field_behavior) = REQUIRED,
70+
(google.api.resource_reference) = {
71+
type: "chat.googleapis.com/ThreadReadState"
72+
}
73+
];
74+
}

0 commit comments

Comments
 (0)