rooms.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "chatto/api/v1/attachments.proto";
  5. import "chatto/api/v1/common.proto";
  6. import "chatto/api/v1/member_directory.proto";
  7. import "chatto/api/v1/pagination.proto";
  8. import "chatto/api/v1/read_state.proto";
  9. import "chatto/api/v1/room_timeline.proto";
  10. import "google/protobuf/timestamp.proto";
  11. // Kind of room represented by the public API.
  12. enum RoomKind {
  13. // The room kind was not specified.
  14. ROOM_KIND_UNSPECIFIED = 0;
  15. // A regular channel governed by server and room permissions.
  16. ROOM_KIND_CHANNEL = 1;
  17. // A direct-message conversation between members.
  18. ROOM_KIND_DM = 2;
  19. }
  20. // Public room metadata returned by room commands.
  21. message Room {
  22. // Stable room ID.
  23. string id = 1;
  24. // Room kind.
  25. RoomKind kind = 2;
  26. // Room name. Direct-message rooms may have an empty name because clients
  27. // derive their display label from participants.
  28. string name = 3;
  29. // Optional room description.
  30. string description = 4;
  31. // True when the room is archived and hidden from active room lists.
  32. bool archived = 5;
  33. // Room group ID for channel rooms. Empty for direct-message rooms.
  34. string group_id = 6;
  35. // True when a channel grants effective membership to eligible server members.
  36. bool universal = 7;
  37. }
  38. // Lightweight room reference for cross-resource rows.
  39. message RoomSummary {
  40. // Stable room ID.
  41. string id = 1;
  42. // Room kind.
  43. RoomKind kind = 2;
  44. // Room name. Direct-message rooms may have an empty name because clients
  45. // derive their display label from participants.
  46. string name = 3;
  47. }
  48. // Request to create a channel room.
  49. message CreateRoomRequest {
  50. // Required. Name of the new channel room.
  51. string name = 1 [(buf.validate.field).string = {
  52. min_len: 1
  53. max_len: 30
  54. }];
  55. // Optional room description.
  56. string description = 2 [(buf.validate.field).string.max_len = 500];
  57. // Required. Room group that should contain the new channel.
  58. string group_id = 3 [(buf.validate.field).string.min_len = 1];
  59. // Whether the new channel should grant effective membership to eligible
  60. // server members.
  61. bool universal = 4;
  62. }
  63. // Result of creating a room.
  64. message CreateRoomResponse {
  65. // Created room.
  66. Room room = 1;
  67. }
  68. // Request to update a room's editable metadata.
  69. message UpdateRoomRequest {
  70. // Required. Room to update.
  71. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  72. // New room name, when changing it.
  73. optional string name = 2 [(buf.validate.field).string = {
  74. min_len: 1
  75. max_len: 30
  76. }];
  77. // New room description, when changing it. Empty clears the description.
  78. optional string description = 3 [(buf.validate.field).string.max_len = 500];
  79. // New universal membership state, when changing it. Direct-message rooms
  80. // cannot be universal.
  81. optional bool universal = 4;
  82. }
  83. // Result of updating a room.
  84. message UpdateRoomResponse {
  85. // Updated room.
  86. Room room = 1;
  87. }
  88. // Request to archive a room.
  89. message ArchiveRoomRequest {
  90. // Required. Room to archive.
  91. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  92. }
  93. // Result of archiving a room.
  94. message ArchiveRoomResponse {
  95. // Archived room.
  96. Room room = 1;
  97. }
  98. // Request to unarchive a room.
  99. message UnarchiveRoomRequest {
  100. // Required. Room to unarchive.
  101. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  102. }
  103. // Result of unarchiving a room.
  104. message UnarchiveRoomResponse {
  105. // Unarchived room.
  106. Room room = 1;
  107. }
  108. // Request to join a room as the current user.
  109. message JoinRoomRequest {
  110. // Required. Room to join.
  111. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  112. }
  113. // Result of joining a room.
  114. message JoinRoomResponse {
  115. // Joined room.
  116. Room room = 1;
  117. }
  118. // Request to join all joinable rooms in one room group.
  119. message JoinRoomGroupRequest {
  120. // Required. Room group whose rooms should be joined.
  121. string group_id = 1 [(buf.validate.field).string.min_len = 1];
  122. }
  123. // Result of joining all joinable rooms in one room group.
  124. message JoinRoomGroupResponse {
  125. // Room IDs that transitioned from not joined to joined.
  126. repeated string joined_room_ids = 1;
  127. }
  128. // Request to start or fetch a direct-message room.
  129. message StartDMRequest {
  130. // Other participants to include in the direct-message room. The current user
  131. // is always included by the server. An empty list creates or fetches the
  132. // caller's self-DM.
  133. repeated string participant_ids = 1 [(buf.validate.field).repeated = {
  134. max_items: 9
  135. items: {
  136. string: {min_len: 1}
  137. }
  138. }];
  139. }
  140. // Result of starting or fetching a direct-message room.
  141. message StartDMResponse {
  142. // Direct-message room for the participant set.
  143. Room room = 1;
  144. }
  145. // Request to leave a room as the current user.
  146. message LeaveRoomRequest {
  147. // Required. Room to leave.
  148. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  149. }
  150. // Result of leaving a room.
  151. message LeaveRoomResponse {
  152. // True when the current user is no longer an explicit member after the call.
  153. bool left = 1;
  154. }
  155. // Request to add a user to a channel room.
  156. message AddMemberRequest {
  157. // Required. Channel room to add the user to.
  158. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  159. // Required. User to add as an explicit room member.
  160. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  161. }
  162. // Result of adding a user to a room.
  163. message AddMemberResponse {
  164. // Added room member.
  165. DirectoryMember member = 1;
  166. }
  167. // Request to remove a user from a channel room.
  168. message RemoveMemberRequest {
  169. // Required. Channel room to remove the user from.
  170. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  171. // Required. User to remove from the room's explicit members.
  172. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  173. }
  174. // Result of removing a user from a room.
  175. message RemoveMemberResponse {
  176. // True when an explicit room membership was removed by this call.
  177. bool removed = 1;
  178. }
  179. // Request to ban a member from a channel room.
  180. message BanMemberRequest {
  181. // Required. Channel room to ban the user from.
  182. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  183. // Required. User to ban from the room.
  184. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  185. // Required moderator-entered reason stored for audit.
  186. string reason = 3 [(buf.validate.field).string = {
  187. min_len: 1
  188. max_len: 1000
  189. }];
  190. // Optional future time when the ban expires.
  191. google.protobuf.Timestamp expires_at = 4;
  192. }
  193. // Result of banning a room member.
  194. message BanMemberResponse {
  195. // True when the ban operation completed.
  196. bool banned = 1;
  197. }
  198. // Request to remove a channel room ban.
  199. message UnbanMemberRequest {
  200. // Required. Channel room to unban the user from.
  201. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  202. // Required. User to unban.
  203. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  204. // Required moderator-entered reason stored for audit.
  205. string reason = 3 [(buf.validate.field).string = {
  206. min_len: 1
  207. max_len: 1000
  208. }];
  209. }
  210. // Result of removing a room ban.
  211. message UnbanMemberResponse {
  212. // True when the unban operation completed.
  213. bool unbanned = 1;
  214. }
  215. // Active channel room ban with optional hydrated room and user references.
  216. message RoomBan {
  217. // Stable ban event ID.
  218. string id = 1;
  219. // Channel room ID.
  220. string room_id = 2;
  221. // Channel room metadata, when the referenced room still exists.
  222. Room room = 3;
  223. // Banned user ID.
  224. string user_id = 4;
  225. // Banned user profile, when the referenced user still exists.
  226. DirectoryMember user = 5;
  227. // Moderator user ID that created the ban.
  228. string moderator_id = 6;
  229. // Moderator profile, when the referenced user still exists.
  230. DirectoryMember moderator = 7;
  231. // Moderator-entered ban reason.
  232. string reason = 8;
  233. // Time the ban was created.
  234. google.protobuf.Timestamp created_at = 9;
  235. // Optional future time when the ban expires.
  236. google.protobuf.Timestamp expires_at = 10;
  237. }
  238. // Request to list active room bans.
  239. message ListBansRequest {
  240. // Optional channel room filter. Empty lists active bans across all rooms.
  241. string room_id = 1;
  242. // Page request. Defaults are applied when absent or limit is zero.
  243. PageRequest page = 2;
  244. }
  245. // Active room bans visible to the current moderator.
  246. message ListBansResponse {
  247. // Active bans, newest first.
  248. repeated RoomBan bans = 1;
  249. // Page metadata.
  250. PageInfo page = 2;
  251. }
  252. // Request for room-scoped attachment list pages.
  253. message ListRoomAttachmentsRequest {
  254. reserved 2, 3;
  255. reserved "limit", "offset";
  256. // Required room ID.
  257. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  258. // Thumbnail URL options. Defaults are applied when absent.
  259. ImageTransformOptions thumbnail = 4;
  260. // Page request. Defaults are applied when absent or limit is zero.
  261. PageRequest page = 5;
  262. }
  263. // Room-scoped attachment list response.
  264. message ListRoomAttachmentsResponse {
  265. reserved 2, 3;
  266. reserved "total_count", "has_more";
  267. // Current attachments in newest message order.
  268. repeated RoomAttachmentListItem attachments = 1;
  269. // Page metadata.
  270. PageInfo page = 4;
  271. }
  272. // Request to refresh the current user's live-only typing indicator.
  273. message UpdateTypingIndicatorRequest {
  274. // Required. Room where the current user is typing.
  275. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  276. // Event ID of the thread root when typing inside a thread.
  277. string thread_root_event_id = 2;
  278. }
  279. // Result of refreshing a typing indicator.
  280. message UpdateTypingIndicatorResponse {
  281. // True when the typing indicator was accepted for publish.
  282. bool updated = 1;
  283. }
  284. // Manages room-scoped operations for the current user.
  285. //
  286. // RoomService owns operations whose authorization and state are primarily scoped
  287. // to one room, including lifecycle, membership, moderation, room timeline reads,
  288. // room read state, attachments, and live typing. Resource-specific services
  289. // should still be preferred when an operation is not naturally room-scoped or
  290. // when the resource needs an independent CRUD/batch surface.
  291. service RoomService {
  292. // Creates a new channel room in a room group. The caller must be allowed to
  293. // create rooms in the target group.
  294. rpc CreateRoom(CreateRoomRequest) returns (CreateRoomResponse);
  295. // Updates a room's editable metadata. The caller must be allowed to manage
  296. // rooms. Direct-message rooms cannot be universal.
  297. rpc UpdateRoom(UpdateRoomRequest) returns (UpdateRoomResponse);
  298. // Archives a room so it is hidden from active room lists. The caller must be
  299. // allowed to manage rooms.
  300. rpc ArchiveRoom(ArchiveRoomRequest) returns (ArchiveRoomResponse);
  301. // Restores an archived room to active room lists. The caller must be allowed
  302. // to manage rooms.
  303. rpc UnarchiveRoom(UnarchiveRoomRequest) returns (UnarchiveRoomResponse);
  304. // Joins the room as the current user when room permissions allow it.
  305. rpc JoinRoom(JoinRoomRequest) returns (JoinRoomResponse);
  306. // Joins every unarchived room in a group that the current user can join.
  307. // Already-joined and non-joinable rooms are skipped.
  308. rpc JoinRoomGroup(JoinRoomGroupRequest) returns (JoinRoomGroupResponse);
  309. // Starts or fetches a direct-message room for the current user and the
  310. // requested participant set. The caller must be allowed to start DMs.
  311. rpc StartDM(StartDMRequest) returns (StartDMResponse);
  312. // Leaves the room as the current user. Direct-message and universal rooms
  313. // cannot be left.
  314. rpc LeaveRoom(LeaveRoomRequest) returns (LeaveRoomResponse);
  315. // Lists explicit members of a room. The caller must be a member of the room.
  316. rpc ListMembers(ListRoomMembersRequest) returns (ListRoomMembersResponse);
  317. // Gets one explicit member of a room. The caller must be a member of the
  318. // room. Returns NOT_FOUND when the target is unknown or not a room member.
  319. rpc GetMember(GetRoomMemberRequest) returns (GetRoomMemberResponse);
  320. // Gets explicit room member rows for multiple users. The caller must be a
  321. // member of the room.
  322. rpc BatchGetMembers(BatchGetRoomMembersRequest) returns (BatchGetRoomMembersResponse);
  323. // Adds a user as an explicit member of a channel room. The caller must be
  324. // allowed to manage the room. Direct-message and universal rooms cannot be
  325. // managed this way.
  326. rpc AddMember(AddMemberRequest) returns (AddMemberResponse);
  327. // Removes a user from a channel room's explicit members. The caller must be
  328. // allowed to manage the room. Direct-message and universal rooms cannot be
  329. // managed this way.
  330. rpc RemoveMember(RemoveMemberRequest) returns (RemoveMemberResponse);
  331. // Lists active channel room bans. The caller must be allowed to moderate room
  332. // membership bans.
  333. rpc ListBans(ListBansRequest) returns (ListBansResponse);
  334. // Lists current message-owned room attachments. Authentication and room
  335. // membership are required. Returns PERMISSION_DENIED when the room is
  336. // inaccessible to the caller.
  337. rpc ListRoomAttachments(ListRoomAttachmentsRequest) returns (ListRoomAttachmentsResponse);
  338. // Refreshes the current user's live-only typing indicator for a room or
  339. // thread. Room membership is required; message posting permission is not.
  340. rpc UpdateTypingIndicator(UpdateTypingIndicatorRequest) returns (UpdateTypingIndicatorResponse);
  341. // Returns one page of room timeline events, including related user data needed
  342. // to render the page.
  343. rpc GetRoomEvents(GetRoomEventsRequest) returns (GetRoomEventsResponse);
  344. // Returns a room timeline window centered around a specific event. Use this to
  345. // open a permalink, search result, or notification target in context. Returns
  346. // NOT_FOUND when the anchor event is missing or not visible in the room
  347. // timeline and PERMISSION_DENIED when the room is inaccessible.
  348. rpc GetRoomEventsAround(GetRoomEventsAroundRequest) returns (GetRoomEventsAroundResponse);
  349. // Marks a room timeline as read through the supplied event. If no event is
  350. // supplied, the server marks through the room's latest root event. Clients
  351. // usually call this after the user has viewed the latest visible event in the
  352. // room.
  353. rpc MarkRoomAsRead(MarkRoomAsReadRequest) returns (MarkRoomAsReadResponse);
  354. // Bans a member from a channel room. Direct-message rooms cannot be moderated
  355. // this way, and the target must currently be a room member.
  356. rpc BanMember(BanMemberRequest) returns (BanMemberResponse);
  357. // Removes an active channel room ban. Calling this when no active ban exists
  358. // is allowed and still returns success.
  359. rpc UnbanMember(UnbanMemberRequest) returns (UnbanMemberResponse);
  360. }