room_directory.proto 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "chatto/api/v1/permissions.proto";
  5. import "chatto/api/v1/pagination.proto";
  6. import "chatto/api/v1/rooms.proto";
  7. import "google/protobuf/timestamp.proto";
  8. // Viewer-specific state and permission decisions for one room.
  9. message RoomViewerState {
  10. // True when the current user is an effective room member.
  11. bool is_member = 1;
  12. // True when the room has neutral Badge attention for the current user.
  13. // This state is independent of the user's last-read message cursor.
  14. bool has_unread = 2;
  15. // Effective room-scoped permission decisions after room state constraints.
  16. repeated PermissionGrant permissions = 3;
  17. // Earliest time the current user may create another message. Absent when
  18. // slow mode is disabled, expired, or bypassed by moderation permissions.
  19. google.protobuf.Timestamp slow_mode_next_post_at = 4;
  20. }
  21. // Room kinds to include in directory responses.
  22. enum RoomDirectoryScope {
  23. // Include visible channel rooms and the caller's DM rooms.
  24. ROOM_DIRECTORY_SCOPE_UNSPECIFIED = 0;
  25. // Include visible channel rooms and the caller's DM rooms.
  26. ROOM_DIRECTORY_SCOPE_ALL = 1;
  27. // Include visible channel rooms only.
  28. ROOM_DIRECTORY_SCOPE_CHANNELS = 2;
  29. // Include the caller's DM rooms only.
  30. ROOM_DIRECTORY_SCOPE_DMS = 3;
  31. }
  32. // Archive state to include in room directory responses.
  33. enum RoomArchiveFilter {
  34. // Include active rooms only.
  35. ROOM_ARCHIVE_FILTER_UNSPECIFIED = 0;
  36. // Include active rooms only.
  37. ROOM_ARCHIVE_FILTER_ACTIVE = 1;
  38. // Include archived rooms only.
  39. ROOM_ARCHIVE_FILTER_ARCHIVED = 2;
  40. // Include both active and archived rooms.
  41. ROOM_ARCHIVE_FILTER_ALL = 3;
  42. }
  43. // Room metadata plus state and capabilities resolved for the authenticated
  44. // viewer.
  45. message RoomWithViewerState {
  46. reserved 2 to 13;
  47. reserved "is_member", "has_unread", "can_list_room", "can_join_room", "can_post_message", "can_post_in_thread", "can_attach", "can_react", "can_echo_message", "can_manage_others_message", "can_manage_room", "can_ban_room_members";
  48. // Public room metadata.
  49. Room room = 1;
  50. // State and permission decisions resolved for the current user.
  51. RoomViewerState viewer_state = 14;
  52. // Complete participant user IDs for a DM, including participants whose
  53. // accounts were deleted. Clients show those as deleted users. Empty for
  54. // channel rooms.
  55. repeated string member_user_ids = 15;
  56. // Whether this DM has received a root message. Absent for channel rooms.
  57. optional bool has_message_history = 16;
  58. }
  59. // Sidebar link metadata for room group navigation.
  60. message SidebarLink {
  61. // Stable sidebar link ID.
  62. string id = 1;
  63. // Display label.
  64. string label = 2;
  65. // Absolute http(s) URL or server-local path.
  66. string url = 3;
  67. }
  68. // One ordered item in a room group.
  69. message RoomGroupItem {
  70. oneof item {
  71. // Visible room entry.
  72. RoomWithViewerState room = 1;
  73. // Sidebar link entry.
  74. SidebarLink sidebar_link = 2;
  75. }
  76. }
  77. // Viewer-specific state for one room group.
  78. message RoomGroupViewerState {
  79. reserved 1;
  80. reserved "can_create_room";
  81. // Effective group-scoped permission decisions after group state constraints.
  82. repeated PermissionGrant permissions = 2;
  83. }
  84. // Ordered group of channel rooms and sidebar links.
  85. message RoomGroup {
  86. reserved 4;
  87. reserved "rooms";
  88. // Stable room group ID.
  89. string id = 1;
  90. // Display name.
  91. string name = 2;
  92. // Public group description, when set.
  93. string description = 3;
  94. // Mixed room/sidebar-link entries in sidebar order.
  95. repeated RoomGroupItem items = 5;
  96. // State and permissions resolved for the current user.
  97. RoomGroupViewerState viewer_state = 6;
  98. }
  99. // Request for rooms visible to the current user.
  100. message ListRoomsRequest {
  101. // Which room kinds to include. Defaults to all.
  102. RoomDirectoryScope scope = 1 [(buf.validate.field).enum.defined_only = true];
  103. // Archive state to include. Defaults to ACTIVE. Combined with scope; this
  104. // filter does not grant access to hidden rooms.
  105. RoomArchiveFilter archive_filter = 2 [(buf.validate.field).enum.defined_only = true];
  106. // Defaults to 50 rooms, capped at 100. Rooms are ordered by ID ascending.
  107. PageRequest page = 3;
  108. }
  109. // One live page of rooms visible to the current user. Changes between requests
  110. // can shift offsets. Follow page.has_more to read the complete directory.
  111. message ListRoomsResponse {
  112. // Visible rooms matching both the room-kind scope and archive filter.
  113. repeated RoomWithViewerState rooms = 1;
  114. // Count after visibility, scope, and archive filters, before pagination.
  115. PageInfo page = 2;
  116. }
  117. // Request for ordered room groups visible to the current user.
  118. message ListRoomGroupsRequest {
  119. reserved 1;
  120. reserved "include_archived_rooms";
  121. }
  122. // Finite snapshot of ordered room groups visible to the current user.
  123. message ListRoomGroupsResponse {
  124. // Channel room groups in sidebar order.
  125. repeated RoomGroup groups = 1;
  126. }
  127. // Request for one ordered room group visible to the current user.
  128. message GetRoomGroupRequest {
  129. reserved 2;
  130. reserved "include_archived_rooms";
  131. // Required. Room group to resolve.
  132. string group_id = 1 [(buf.validate.field).string.min_len = 1];
  133. }
  134. // One ordered room group visible to the current user.
  135. message GetRoomGroupResponse {
  136. // Resolved room group. Hidden and archived room entries are omitted.
  137. RoomGroup group = 1;
  138. }
  139. // Request visible room groups by stable group ID.
  140. message BatchGetRoomGroupsRequest {
  141. reserved 2;
  142. reserved "include_archived_rooms";
  143. // Required room group IDs. Unknown groups are omitted from the response.
  144. repeated string group_ids = 1 [(buf.validate.field).repeated = {
  145. min_items: 1
  146. max_items: 100
  147. items: {
  148. string: {min_len: 1}
  149. }
  150. }];
  151. }
  152. // Visible room group batch response for direct group hydration.
  153. message BatchGetRoomGroupsResponse {
  154. // Resolved room groups in first-seen request order.
  155. repeated RoomGroup groups = 1;
  156. }
  157. // Request for one room visible to the current user.
  158. message GetRoomRequest {
  159. // Required. Room to resolve.
  160. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  161. }
  162. // Room visible to the current user.
  163. message GetRoomResponse {
  164. // Resolved room and viewer state.
  165. RoomWithViewerState room = 1;
  166. }
  167. // Request visible rooms by stable room ID.
  168. message BatchGetRoomsRequest {
  169. // Required room IDs. Unknown rooms and rooms hidden from the caller are
  170. // omitted from the response. Archived rooms may be returned when the caller
  171. // can still refresh them directly.
  172. repeated string room_ids = 1 [(buf.validate.field).repeated = {
  173. min_items: 1
  174. max_items: 100
  175. items: {
  176. string: {min_len: 1}
  177. }
  178. }];
  179. }
  180. // Visible room batch response for direct room hydration.
  181. message BatchGetRoomsResponse {
  182. // Resolved rooms in first-seen request order.
  183. repeated RoomWithViewerState rooms = 1;
  184. }
  185. // Reads room directory data.
  186. service RoomDirectoryService {
  187. // Lists rooms visible to the current user. Defaults to active rooms; use
  188. // archive_filter to discover archived rooms or include both states. Channel
  189. // rooms require membership or room.list. DM membership exposes room and
  190. // participant metadata. Message-derived DM state also requires current
  191. // read permission. Accessible empty DMs are included. Returns up to 100 rooms
  192. // ordered by ID ascending; the default page size is 50.
  193. rpc ListRooms(ListRoomsRequest) returns (ListRoomsResponse);
  194. // Lists ordered channel room groups and sidebar items visible to the current
  195. // user as a finite navigation snapshot. Hidden room entries are omitted.
  196. // Archived room entries are omitted.
  197. rpc ListRoomGroups(ListRoomGroupsRequest) returns (ListRoomGroupsResponse);
  198. // Returns one ordered room group by ID. Hidden room entries are omitted.
  199. // Archived room entries are omitted.
  200. // Returns NOT_FOUND when the room group does not exist.
  201. rpc GetRoomGroup(GetRoomGroupRequest) returns (GetRoomGroupResponse);
  202. // Returns ordered room groups for a set of stable group IDs. Hidden room
  203. // entries are omitted. Archived room entries are omitted. Unknown groups are
  204. // omitted. Results preserve first-seen request order and repeated IDs are
  205. // de-duplicated.
  206. rpc BatchGetRoomGroups(BatchGetRoomGroupsRequest) returns (BatchGetRoomGroupsResponse);
  207. // Returns one visible room by ID. DM rooms require membership. Returns
  208. // NOT_FOUND when the room does not exist and PERMISSION_DENIED when the room
  209. // exists but is hidden from the caller.
  210. rpc GetRoom(GetRoomRequest) returns (GetRoomResponse);
  211. // Returns visible rooms for a set of stable room IDs. This is a direct
  212. // hydration API, so visible archived rooms may be returned. Unknown rooms and
  213. // rooms hidden from the caller are omitted. Results preserve first-seen
  214. // request order and repeated IDs are de-duplicated.
  215. rpc BatchGetRooms(BatchGetRoomsRequest) returns (BatchGetRoomsResponse);
  216. }