rooms.proto 15 KB

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