room_directory.proto 7.0 KB

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