room_directory.proto 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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/rooms.proto";
  6. import "google/protobuf/timestamp.proto";
  7. // Viewer-specific state and permission decisions for one room.
  8. message RoomViewerState {
  9. // True when the current user is an effective room member.
  10. bool is_member = 1;
  11. // True when the room has neutral Badge attention for the current user.
  12. // This state is independent of the user's last-read message cursor.
  13. bool has_unread = 2;
  14. // Effective room-scoped permission decisions after room state constraints.
  15. repeated PermissionGrant permissions = 3;
  16. // Earliest time the current user may create another message. Absent when
  17. // slow mode is disabled, expired, or bypassed by moderation permissions.
  18. google.protobuf.Timestamp slow_mode_next_post_at = 4;
  19. }
  20. // Room kinds to include in directory responses.
  21. enum RoomDirectoryScope {
  22. // Include visible channel rooms and readable active DM rooms.
  23. ROOM_DIRECTORY_SCOPE_UNSPECIFIED = 0;
  24. // Include visible channel rooms and readable active DM rooms.
  25. ROOM_DIRECTORY_SCOPE_ALL = 1;
  26. // Include visible channel rooms only.
  27. ROOM_DIRECTORY_SCOPE_CHANNELS = 2;
  28. // Include the caller's readable active DM rooms only.
  29. ROOM_DIRECTORY_SCOPE_DMS = 3;
  30. }
  31. // Room metadata plus state and capabilities resolved for the authenticated
  32. // viewer.
  33. message RoomWithViewerState {
  34. reserved 2 to 13;
  35. 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";
  36. // Public room metadata.
  37. Room room = 1;
  38. // State and permission decisions resolved for the current user.
  39. RoomViewerState viewer_state = 14;
  40. }
  41. // Sidebar link metadata for room group navigation.
  42. message SidebarLink {
  43. // Stable sidebar link ID.
  44. string id = 1;
  45. // Display label.
  46. string label = 2;
  47. // Absolute http(s) URL or server-local path.
  48. string url = 3;
  49. }
  50. // One ordered item in a room group.
  51. message RoomGroupItem {
  52. oneof item {
  53. // Visible room entry.
  54. RoomWithViewerState room = 1;
  55. // Sidebar link entry.
  56. SidebarLink sidebar_link = 2;
  57. }
  58. }
  59. // Viewer-specific state for one room group.
  60. message RoomGroupViewerState {
  61. reserved 1;
  62. reserved "can_create_room";
  63. // Effective group-scoped permission decisions after group state constraints.
  64. repeated PermissionGrant permissions = 2;
  65. }
  66. // Ordered group of channel rooms and sidebar links.
  67. message RoomGroup {
  68. reserved 4;
  69. reserved "rooms";
  70. // Stable room group ID.
  71. string id = 1;
  72. // Display name.
  73. string name = 2;
  74. // Public group description, when set.
  75. string description = 3;
  76. // Mixed room/sidebar-link entries in sidebar order.
  77. repeated RoomGroupItem items = 5;
  78. // State and permissions resolved for the current user.
  79. RoomGroupViewerState viewer_state = 6;
  80. }
  81. // Request for rooms visible to the current user.
  82. message ListRoomsRequest {
  83. // Which room kinds to include. Defaults to all.
  84. RoomDirectoryScope scope = 1 [(buf.validate.field).enum.defined_only = true];
  85. }
  86. // Finite snapshot of rooms visible to the current user.
  87. message ListRoomsResponse {
  88. // Rooms matching the requested scope.
  89. repeated RoomWithViewerState rooms = 1;
  90. }
  91. // Request for ordered room groups visible to the current user.
  92. message ListRoomGroupsRequest {
  93. reserved 1;
  94. reserved "include_archived_rooms";
  95. }
  96. // Finite snapshot of ordered room groups visible to the current user.
  97. message ListRoomGroupsResponse {
  98. // Channel room groups in sidebar order.
  99. repeated RoomGroup groups = 1;
  100. }
  101. // Request for one ordered room group visible to the current user.
  102. message GetRoomGroupRequest {
  103. reserved 2;
  104. reserved "include_archived_rooms";
  105. // Required. Room group to resolve.
  106. string group_id = 1 [(buf.validate.field).string.min_len = 1];
  107. }
  108. // One ordered room group visible to the current user.
  109. message GetRoomGroupResponse {
  110. // Resolved room group. Hidden and archived room entries are omitted.
  111. RoomGroup group = 1;
  112. }
  113. // Request visible room groups by stable group ID.
  114. message BatchGetRoomGroupsRequest {
  115. reserved 2;
  116. reserved "include_archived_rooms";
  117. // Required room group IDs. Unknown groups are omitted from the response.
  118. repeated string group_ids = 1 [(buf.validate.field).repeated = {
  119. min_items: 1
  120. max_items: 100
  121. items: {
  122. string: {min_len: 1}
  123. }
  124. }];
  125. }
  126. // Visible room group batch response for direct group hydration.
  127. message BatchGetRoomGroupsResponse {
  128. // Resolved room groups in first-seen request order.
  129. repeated RoomGroup groups = 1;
  130. }
  131. // Request for one room visible to the current user.
  132. message GetRoomRequest {
  133. // Required. Room to resolve.
  134. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  135. }
  136. // Room visible to the current user.
  137. message GetRoomResponse {
  138. // Resolved room and viewer state.
  139. RoomWithViewerState room = 1;
  140. }
  141. // Request visible rooms by stable room ID.
  142. message BatchGetRoomsRequest {
  143. // Required room IDs. Unknown rooms and rooms hidden from the caller are
  144. // omitted from the response. Archived rooms may be returned when the caller
  145. // can still refresh them directly.
  146. repeated string room_ids = 1 [(buf.validate.field).repeated = {
  147. min_items: 1
  148. max_items: 100
  149. items: {
  150. string: {min_len: 1}
  151. }
  152. }];
  153. }
  154. // Visible room batch response for direct room hydration.
  155. message BatchGetRoomsResponse {
  156. // Resolved rooms in first-seen request order.
  157. repeated RoomWithViewerState rooms = 1;
  158. }
  159. // Reads room directory data.
  160. service RoomDirectoryService {
  161. // Lists rooms visible to the current user. Channel rooms are non-archived
  162. // rooms visible through membership or room.list. DM membership authorizes DM
  163. // reads. Empty DMs are omitted. Results are returned as a finite navigation
  164. // snapshot.
  165. rpc ListRooms(ListRoomsRequest) returns (ListRoomsResponse);
  166. // Lists ordered channel room groups and sidebar items visible to the current
  167. // user as a finite navigation snapshot. Hidden room entries are omitted.
  168. // Archived room entries are omitted.
  169. rpc ListRoomGroups(ListRoomGroupsRequest) returns (ListRoomGroupsResponse);
  170. // Returns one ordered room group by ID. Hidden room entries are omitted.
  171. // Archived room entries are omitted.
  172. // Returns NOT_FOUND when the room group does not exist.
  173. rpc GetRoomGroup(GetRoomGroupRequest) returns (GetRoomGroupResponse);
  174. // Returns ordered room groups for a set of stable group IDs. Hidden room
  175. // entries are omitted. Archived room entries are omitted. Unknown groups are
  176. // omitted. Results preserve first-seen request order and repeated IDs are
  177. // de-duplicated.
  178. rpc BatchGetRoomGroups(BatchGetRoomGroupsRequest) returns (BatchGetRoomGroupsResponse);
  179. // Returns one visible room by ID. DM rooms require membership. Returns
  180. // NOT_FOUND when the room does not exist and PERMISSION_DENIED when the room
  181. // exists but is hidden from the caller.
  182. rpc GetRoom(GetRoomRequest) returns (GetRoomResponse);
  183. // Returns visible rooms for a set of stable room IDs. This is a direct
  184. // hydration API, so visible archived rooms may be returned. Unknown rooms and
  185. // rooms hidden from the caller are omitted. Results preserve first-seen
  186. // request order and repeated IDs are de-duplicated.
  187. rpc BatchGetRooms(BatchGetRoomsRequest) returns (BatchGetRoomsResponse);
  188. }