room_directory.proto 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. Empty for channel rooms.
  53. repeated string member_user_ids = 15;
  54. // Whether this DM has received a root message. Absent for channel rooms.
  55. optional bool has_message_history = 16;
  56. }
  57. // Sidebar link metadata for room group navigation.
  58. message SidebarLink {
  59. // Stable sidebar link ID.
  60. string id = 1;
  61. // Display label.
  62. string label = 2;
  63. // Absolute http(s) URL or server-local path.
  64. string url = 3;
  65. }
  66. // One ordered item in a room group.
  67. message RoomGroupItem {
  68. oneof item {
  69. // Visible room entry.
  70. RoomWithViewerState room = 1;
  71. // Sidebar link entry.
  72. SidebarLink sidebar_link = 2;
  73. }
  74. }
  75. // Viewer-specific state for one room group.
  76. message RoomGroupViewerState {
  77. reserved 1;
  78. reserved "can_create_room";
  79. // Effective group-scoped permission decisions after group state constraints.
  80. repeated PermissionGrant permissions = 2;
  81. }
  82. // Ordered group of channel rooms and sidebar links.
  83. message RoomGroup {
  84. reserved 4;
  85. reserved "rooms";
  86. // Stable room group ID.
  87. string id = 1;
  88. // Display name.
  89. string name = 2;
  90. // Public group description, when set.
  91. string description = 3;
  92. // Mixed room/sidebar-link entries in sidebar order.
  93. repeated RoomGroupItem items = 5;
  94. // State and permissions resolved for the current user.
  95. RoomGroupViewerState viewer_state = 6;
  96. }
  97. // Request for rooms visible to the current user.
  98. message ListRoomsRequest {
  99. // Which room kinds to include. Defaults to all.
  100. RoomDirectoryScope scope = 1 [(buf.validate.field).enum.defined_only = true];
  101. // Archive state to include. Defaults to ACTIVE. Combined with scope; this
  102. // filter does not grant access to hidden rooms.
  103. RoomArchiveFilter archive_filter = 2 [(buf.validate.field).enum.defined_only = true];
  104. // Defaults to 50 rooms, capped at 100. Rooms are ordered by ID ascending.
  105. PageRequest page = 3;
  106. }
  107. // One live page of rooms visible to the current user. Changes between requests
  108. // can shift offsets. Follow page.has_more to read the complete directory.
  109. message ListRoomsResponse {
  110. // Visible rooms matching both the room-kind scope and archive filter.
  111. repeated RoomWithViewerState rooms = 1;
  112. // Count after visibility, scope, and archive filters, before pagination.
  113. PageInfo page = 2;
  114. }
  115. // Request for ordered room groups visible to the current user.
  116. message ListRoomGroupsRequest {
  117. reserved 1;
  118. reserved "include_archived_rooms";
  119. }
  120. // Finite snapshot of ordered room groups visible to the current user.
  121. message ListRoomGroupsResponse {
  122. // Channel room groups in sidebar order.
  123. repeated RoomGroup groups = 1;
  124. }
  125. // Request for one ordered room group visible to the current user.
  126. message GetRoomGroupRequest {
  127. reserved 2;
  128. reserved "include_archived_rooms";
  129. // Required. Room group to resolve.
  130. string group_id = 1 [(buf.validate.field).string.min_len = 1];
  131. }
  132. // One ordered room group visible to the current user.
  133. message GetRoomGroupResponse {
  134. // Resolved room group. Hidden and archived room entries are omitted.
  135. RoomGroup group = 1;
  136. }
  137. // Request visible room groups by stable group ID.
  138. message BatchGetRoomGroupsRequest {
  139. reserved 2;
  140. reserved "include_archived_rooms";
  141. // Required room group IDs. Unknown groups are omitted from the response.
  142. repeated string group_ids = 1 [(buf.validate.field).repeated = {
  143. min_items: 1
  144. max_items: 100
  145. items: {
  146. string: {min_len: 1}
  147. }
  148. }];
  149. }
  150. // Visible room group batch response for direct group hydration.
  151. message BatchGetRoomGroupsResponse {
  152. // Resolved room groups in first-seen request order.
  153. repeated RoomGroup groups = 1;
  154. }
  155. // Request for one room visible to the current user.
  156. message GetRoomRequest {
  157. // Required. Room to resolve.
  158. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  159. }
  160. // Room visible to the current user.
  161. message GetRoomResponse {
  162. // Resolved room and viewer state.
  163. RoomWithViewerState room = 1;
  164. }
  165. // Request visible rooms by stable room ID.
  166. message BatchGetRoomsRequest {
  167. // Required room IDs. Unknown rooms and rooms hidden from the caller are
  168. // omitted from the response. Archived rooms may be returned when the caller
  169. // can still refresh them directly.
  170. repeated string room_ids = 1 [(buf.validate.field).repeated = {
  171. min_items: 1
  172. max_items: 100
  173. items: {
  174. string: {min_len: 1}
  175. }
  176. }];
  177. }
  178. // Visible room batch response for direct room hydration.
  179. message BatchGetRoomsResponse {
  180. // Resolved rooms in first-seen request order.
  181. repeated RoomWithViewerState rooms = 1;
  182. }
  183. // Reads room directory data.
  184. service RoomDirectoryService {
  185. // Lists rooms visible to the current user. Defaults to active rooms; use
  186. // archive_filter to discover archived rooms or include both states. Channel
  187. // rooms require membership or room.list. DM membership exposes room and
  188. // participant metadata. Message-derived DM state also requires current
  189. // read permission. Accessible empty DMs are included. Returns up to 100 rooms
  190. // ordered by ID ascending; the default page size is 50.
  191. rpc ListRooms(ListRoomsRequest) returns (ListRoomsResponse);
  192. // Lists ordered channel room groups and sidebar items visible to the current
  193. // user as a finite navigation snapshot. Hidden room entries are omitted.
  194. // Archived room entries are omitted.
  195. rpc ListRoomGroups(ListRoomGroupsRequest) returns (ListRoomGroupsResponse);
  196. // Returns one ordered room group by ID. Hidden room entries are omitted.
  197. // Archived room entries are omitted.
  198. // Returns NOT_FOUND when the room group does not exist.
  199. rpc GetRoomGroup(GetRoomGroupRequest) returns (GetRoomGroupResponse);
  200. // Returns ordered room groups for a set of stable group IDs. Hidden room
  201. // entries are omitted. Archived room entries are omitted. Unknown groups are
  202. // omitted. Results preserve first-seen request order and repeated IDs are
  203. // de-duplicated.
  204. rpc BatchGetRoomGroups(BatchGetRoomGroupsRequest) returns (BatchGetRoomGroupsResponse);
  205. // Returns one visible room by ID. DM rooms require membership. Returns
  206. // NOT_FOUND when the room does not exist and PERMISSION_DENIED when the room
  207. // exists but is hidden from the caller.
  208. rpc GetRoom(GetRoomRequest) returns (GetRoomResponse);
  209. // Returns visible rooms for a set of stable room IDs. This is a direct
  210. // hydration API, so visible archived rooms may be returned. Unknown rooms and
  211. // rooms hidden from the caller are omitted. Results preserve first-seen
  212. // request order and repeated IDs are de-duplicated.
  213. rpc BatchGetRooms(BatchGetRoomsRequest) returns (BatchGetRoomsResponse);
  214. }