rooms.proto 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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 "chatto/api/v1/message_types.proto";
  11. import "chatto/api/v1/users.proto";
  12. import "google/protobuf/timestamp.proto";
  13. // Kind of room represented by the public API.
  14. enum RoomKind {
  15. // The room kind was not specified.
  16. ROOM_KIND_UNSPECIFIED = 0;
  17. // A regular channel governed by server and room permissions.
  18. ROOM_KIND_CHANNEL = 1;
  19. // A direct-message conversation between members.
  20. ROOM_KIND_DM = 2;
  21. }
  22. // Public room metadata returned by room commands.
  23. message Room {
  24. // Stable room ID.
  25. string id = 1;
  26. // Room kind.
  27. RoomKind kind = 2;
  28. // Room name. Direct-message rooms may have an empty name because clients
  29. // derive their display label from participants.
  30. string name = 3;
  31. // Optional room description.
  32. string description = 4;
  33. // True when the room is archived and hidden from active room lists.
  34. bool archived = 5;
  35. // Room group ID for channel rooms. Empty for direct-message rooms.
  36. string group_id = 6;
  37. // True when a channel grants effective membership to eligible server members.
  38. bool universal = 7;
  39. // Minimum number of seconds a non-exempt member must wait between message
  40. // posts. Channel rooms only; zero means slow mode is disabled.
  41. uint32 slow_mode_seconds = 8;
  42. // Threading policy for this channel room. Direct-message rooms report
  43. // UNSPECIFIED because they do not support threads.
  44. RoomThreadingMode threading_mode = 9;
  45. }
  46. // Lightweight room reference for cross-resource rows.
  47. message RoomSummary {
  48. // Stable room ID.
  49. string id = 1;
  50. // Room kind.
  51. RoomKind kind = 2;
  52. // Room name. Direct-message rooms may have an empty name because clients
  53. // derive their display label from participants.
  54. string name = 3;
  55. }
  56. // Request to create a channel room.
  57. message CreateRoomRequest {
  58. // Required. Visible 1–30-code-point Unicode name of the new channel room.
  59. // The server trims and stores it in NFC form. Control characters and Unicode
  60. // line or paragraph separators are rejected.
  61. string name = 1 [(buf.validate.field).string = {
  62. min_len: 1
  63. max_len: 30
  64. }];
  65. // Optional room description.
  66. string description = 2 [(buf.validate.field).string.max_len = 500];
  67. // Required. Room group that should contain the new channel.
  68. string group_id = 3 [(buf.validate.field).string.min_len = 1];
  69. // Whether the new channel should grant effective membership to eligible
  70. // server members.
  71. bool universal = 4;
  72. // Threading policy for the new channel. UNSPECIFIED selects ENABLED.
  73. RoomThreadingMode threading_mode = 5;
  74. }
  75. // Result of creating a room.
  76. message CreateRoomResponse {
  77. // Created room.
  78. Room room = 1;
  79. }
  80. // Request to update a room's editable metadata.
  81. message UpdateRoomRequest {
  82. // Required. Room to update.
  83. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  84. // New visible 1–30-code-point Unicode room name, when changing it. The server
  85. // trims and stores it in NFC form. Control characters and Unicode line or
  86. // paragraph separators are rejected.
  87. optional string name = 2 [(buf.validate.field).string = {
  88. min_len: 1
  89. max_len: 30
  90. }];
  91. // New room description, when changing it. Empty clears the description.
  92. optional string description = 3 [(buf.validate.field).string.max_len = 500];
  93. // New universal membership state, when changing it. Direct-message rooms
  94. // cannot be universal.
  95. optional bool universal = 4;
  96. // New per-user posting interval in seconds. Zero disables slow mode. The
  97. // maximum supported interval is six hours. Direct-message rooms cannot use
  98. // slow mode.
  99. optional uint32 slow_mode_seconds = 5 [(buf.validate.field).uint32.lte = 21600];
  100. // New threading policy. Direct-message rooms cannot set this field, and an
  101. // explicitly supplied UNSPECIFIED or unknown value is rejected.
  102. optional RoomThreadingMode threading_mode = 6;
  103. }
  104. // Result of updating a room.
  105. message UpdateRoomResponse {
  106. // Updated room.
  107. Room room = 1;
  108. }
  109. // Request to archive a room.
  110. message ArchiveRoomRequest {
  111. // Required. Room to archive.
  112. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  113. }
  114. // Result of archiving a room.
  115. message ArchiveRoomResponse {
  116. // Archived room.
  117. Room room = 1;
  118. }
  119. // Request to unarchive a room.
  120. message UnarchiveRoomRequest {
  121. // Required. Room to unarchive.
  122. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  123. }
  124. // Result of unarchiving a room.
  125. message UnarchiveRoomResponse {
  126. // Unarchived room.
  127. Room room = 1;
  128. }
  129. // Request to join a room as the current user.
  130. message JoinRoomRequest {
  131. // Required. Room to join.
  132. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  133. }
  134. // Result of joining a room.
  135. message JoinRoomResponse {
  136. // Joined room.
  137. Room room = 1;
  138. }
  139. // Request to join all joinable rooms in one room group.
  140. message JoinRoomGroupRequest {
  141. // Required. Room group whose rooms should be joined.
  142. string group_id = 1 [(buf.validate.field).string.min_len = 1];
  143. }
  144. // Result of joining all joinable rooms in one room group.
  145. message JoinRoomGroupResponse {
  146. // Room IDs that transitioned from not joined to joined.
  147. repeated string joined_room_ids = 1;
  148. }
  149. // Request to start a direct-message room for a human caller, or fetch an
  150. // existing one. A human caller can fetch an existing DM without message.post.
  151. // A valid request from a bot receives PERMISSION_DENIED, including when the
  152. // room already exists.
  153. message StartDMRequest {
  154. // Other participants to include in the direct-message room. The current user
  155. // is always included by the server. An empty list creates or fetches the
  156. // caller's self-DM.
  157. repeated string participant_ids = 1 [(buf.validate.field).repeated = {
  158. max_items: 9
  159. items: {
  160. string: {min_len: 1}
  161. }
  162. }];
  163. }
  164. // Result of starting or fetching a direct-message room.
  165. message StartDMResponse {
  166. // Direct-message room for the participant set.
  167. Room room = 1;
  168. }
  169. // Request to leave a room as the current user.
  170. message LeaveRoomRequest {
  171. // Required. Room to leave.
  172. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  173. }
  174. // Result of leaving a room.
  175. message LeaveRoomResponse {
  176. // True when the current user is no longer an explicit member after the call.
  177. bool left = 1;
  178. }
  179. // Request to add a user to a channel room.
  180. message AddMemberRequest {
  181. // Required. Channel room to add the user to.
  182. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  183. // Required. User to add as an explicit room member.
  184. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  185. }
  186. // Result of adding a user to a room.
  187. message AddMemberResponse {
  188. // Added room member.
  189. DirectoryMember member = 1;
  190. }
  191. // Request to remove a user from a channel room.
  192. message RemoveMemberRequest {
  193. // Required. Channel room to remove the user from.
  194. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  195. // Required. User to remove from the room's explicit members.
  196. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  197. }
  198. // Result of removing a user from a room.
  199. message RemoveMemberResponse {
  200. // True when an explicit room membership was removed by this call.
  201. bool removed = 1;
  202. }
  203. // Request to ban a member from a channel room.
  204. message BanMemberRequest {
  205. // Required. Channel room to ban the user from.
  206. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  207. // Required. User to ban from the room.
  208. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  209. // Required moderator-entered reason stored for audit.
  210. string reason = 3 [(buf.validate.field).string = {
  211. min_len: 1
  212. max_len: 1000
  213. }];
  214. // Optional future time when the ban expires.
  215. google.protobuf.Timestamp expires_at = 4;
  216. }
  217. // Result of banning a room member.
  218. message BanMemberResponse {
  219. // True when the ban operation completed.
  220. bool banned = 1;
  221. }
  222. // Request to remove a channel room ban.
  223. message UnbanMemberRequest {
  224. // Required. Channel room to unban the user from.
  225. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  226. // Required. User to unban.
  227. string user_id = 2 [(buf.validate.field).string.min_len = 1];
  228. // Required moderator-entered reason stored for audit.
  229. string reason = 3 [(buf.validate.field).string = {
  230. min_len: 1
  231. max_len: 1000
  232. }];
  233. }
  234. // Result of removing a room ban.
  235. message UnbanMemberResponse {
  236. // True when the unban operation completed.
  237. bool unbanned = 1;
  238. }
  239. // Active channel room ban with optional hydrated room and user references.
  240. message RoomBan {
  241. // Stable ban event ID.
  242. string id = 1;
  243. // Channel room ID.
  244. string room_id = 2;
  245. // Channel room metadata, when the referenced room still exists.
  246. Room room = 3;
  247. // Banned user ID.
  248. string user_id = 4;
  249. // Banned user profile, when the referenced user still exists.
  250. DirectoryMember user = 5;
  251. // Moderator user ID that created the ban.
  252. string moderator_id = 6;
  253. // Moderator profile, when the referenced user still exists.
  254. DirectoryMember moderator = 7;
  255. // Moderator-entered ban reason.
  256. string reason = 8;
  257. // Time the ban was created.
  258. google.protobuf.Timestamp created_at = 9;
  259. // Optional future time when the ban expires.
  260. google.protobuf.Timestamp expires_at = 10;
  261. }
  262. // Request to list active room bans.
  263. message ListBansRequest {
  264. // Optional channel room filter. Empty lists active bans across all rooms.
  265. string room_id = 1;
  266. // Page request. Defaults are applied when absent or limit is zero.
  267. PageRequest page = 2;
  268. }
  269. // Active room bans visible to the current moderator.
  270. message ListBansResponse {
  271. // Active bans, newest first.
  272. repeated RoomBan bans = 1;
  273. // Page metadata.
  274. PageInfo page = 2;
  275. }
  276. // Request for room-scoped attachment list pages.
  277. message ListRoomAttachmentsRequest {
  278. reserved 2, 3;
  279. reserved "limit", "offset";
  280. // Required room ID.
  281. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  282. // Thumbnail URL options. Defaults are applied when absent.
  283. ImageTransformOptions thumbnail = 4;
  284. // Page request. Defaults are applied when absent or limit is zero.
  285. PageRequest page = 5;
  286. }
  287. // Room-scoped attachment list response.
  288. message ListRoomAttachmentsResponse {
  289. reserved 2, 3;
  290. reserved "total_count", "has_more";
  291. // Current attachments in newest message order.
  292. repeated RoomAttachmentListItem attachments = 1;
  293. // Page metadata.
  294. PageInfo page = 4;
  295. }
  296. // One current pinned message in a channel room.
  297. message PinnedMessage {
  298. // Current renderable message. Retracted messages are omitted from pin lists.
  299. Message message = 1;
  300. }
  301. // Request to list a channel room's current pinned messages.
  302. message ListPinnedMessagesRequest {
  303. // Required channel room ID.
  304. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  305. // Page request. Defaults are applied when absent or limit is zero.
  306. PageRequest page = 2;
  307. }
  308. // Current pinned messages in one channel room.
  309. message ListPinnedMessagesResponse {
  310. // Pinned messages in newest-pin-first order.
  311. repeated PinnedMessage pinned_messages = 1;
  312. // Page metadata.
  313. PageInfo page = 2;
  314. // Opaque marker for the latest pin fact observed for this room. The value
  315. // remains stable when pins are removed so clients can detect new pins
  316. // without comparing wall-clock timestamps. Clients must not interpret it.
  317. string latest_pin_marker = 3;
  318. }
  319. // Request to pin a message in a channel room.
  320. message CreatePinnedMessageRequest {
  321. // Required channel room ID.
  322. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  323. // Required canonical message event ID. Thread replies are supported.
  324. string message_event_id = 2 [(buf.validate.field).string.min_len = 1];
  325. }
  326. // Result of pinning a message.
  327. message CreatePinnedMessageResponse {
  328. // Current pinned-message resource. Repeating an existing pin returns it.
  329. PinnedMessage pinned_message = 1;
  330. }
  331. // Request to unpin a message from a channel room.
  332. message DeletePinnedMessageRequest {
  333. // Required channel room ID.
  334. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  335. // Required canonical message event ID.
  336. string message_event_id = 2 [(buf.validate.field).string.min_len = 1];
  337. }
  338. // Result of unpinning a message.
  339. message DeletePinnedMessageResponse {
  340. // True when the message is not pinned after this call.
  341. bool deleted = 1;
  342. }
  343. // Request to refresh the current user's live-only typing indicator.
  344. message UpdateTypingIndicatorRequest {
  345. // Required. Room where the current user is typing.
  346. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  347. // Event ID of the thread root when typing inside a thread.
  348. string thread_root_event_id = 2;
  349. }
  350. // Result of refreshing a typing indicator.
  351. message UpdateTypingIndicatorResponse {
  352. // True when the typing indicator was accepted for publish.
  353. bool updated = 1;
  354. }
  355. // Manages room-scoped operations for the current user.
  356. //
  357. // RoomService owns operations whose authorization and state are primarily scoped
  358. // to one room, including lifecycle, membership, moderation, room timeline reads,
  359. // room read state, attachments, and live typing. Resource-specific services
  360. // should still be preferred when an operation is not naturally room-scoped or
  361. // when the resource needs an independent CRUD/batch surface.
  362. service RoomService {
  363. // Creates a new channel room in a room group. The caller must be allowed to
  364. // create rooms in the target group.
  365. rpc CreateRoom(CreateRoomRequest) returns (CreateRoomResponse);
  366. // Updates a room's editable metadata. The caller must be allowed to manage
  367. // rooms. Direct-message rooms cannot be universal.
  368. rpc UpdateRoom(UpdateRoomRequest) returns (UpdateRoomResponse);
  369. // Archives a room so it is hidden from active room lists. The caller must be
  370. // allowed to manage rooms.
  371. rpc ArchiveRoom(ArchiveRoomRequest) returns (ArchiveRoomResponse);
  372. // Restores an archived room to active room lists. The caller must be allowed
  373. // to manage rooms.
  374. rpc UnarchiveRoom(UnarchiveRoomRequest) returns (UnarchiveRoomResponse);
  375. // Joins the room as the current user when room permissions allow it.
  376. rpc JoinRoom(JoinRoomRequest) returns (JoinRoomResponse);
  377. // Joins every unarchived room in a group that the current user can join.
  378. // Already-joined and non-joinable rooms are skipped.
  379. rpc JoinRoomGroup(JoinRoomGroupRequest) returns (JoinRoomGroupResponse);
  380. // Starts a direct-message room for the current human user and the requested
  381. // participant set, or fetches its existing DM. message.post is required
  382. // only when the DM must be created. A valid request from a bot receives
  383. // PERMISSION_DENIED and cannot use this RPC to fetch an existing DM.
  384. rpc StartDM(StartDMRequest) returns (StartDMResponse);
  385. // Leaves the room as the current user. Direct-message and universal rooms
  386. // cannot be left.
  387. rpc LeaveRoom(LeaveRoomRequest) returns (LeaveRoomResponse);
  388. // Lists effective room members. Existing members and room.manage holders may
  389. // list a channel room; other nonmembers need both room.list and room.join.
  390. rpc ListMembers(ListRoomMembersRequest) returns (ListRoomMembersResponse);
  391. // Gets one explicit member of a room. Existing members and room.manage
  392. // holders may read channel-room members; DMs remain membership-only. Returns
  393. // NOT_FOUND when the target is unknown or not a room member.
  394. rpc GetMember(GetRoomMemberRequest) returns (GetRoomMemberResponse);
  395. // Gets explicit room member rows for multiple users. Existing members and
  396. // room.manage holders may read channel-room members; DMs remain
  397. // membership-only.
  398. rpc BatchGetMembers(BatchGetRoomMembersRequest) returns (BatchGetRoomMembersResponse);
  399. // Adds a user as an explicit member of a channel room. The caller must be
  400. // allowed to manage the room. Direct-message and universal rooms cannot be
  401. // managed this way.
  402. rpc AddMember(AddMemberRequest) returns (AddMemberResponse);
  403. // Removes a user from a channel room's explicit members. The caller must be
  404. // allowed to manage the room. Direct-message and universal rooms cannot be
  405. // managed this way.
  406. rpc RemoveMember(RemoveMemberRequest) returns (RemoveMemberResponse);
  407. // Lists active channel room bans. The caller must be allowed to moderate room
  408. // membership bans.
  409. rpc ListBans(ListBansRequest) returns (ListBansResponse);
  410. // Lists current message-owned room attachments. Authentication and room
  411. // membership are required. Channel-room attachments also require message.read
  412. // or a matching thread relationship with message.read-interactions. DM
  413. // membership authorizes DM attachments. The server omits attachments from
  414. // inaccessible threads. Returns PERMISSION_DENIED when the room is
  415. // inaccessible to the caller.
  416. rpc ListRoomAttachments(ListRoomAttachmentsRequest) returns (ListRoomAttachmentsResponse);
  417. // Lists current pinned messages in a channel room. Room membership plus
  418. // message.read or message.read-interactions are required. The server omits
  419. // pins from threads that the caller cannot read. Direct-message rooms do not
  420. // support pins.
  421. rpc ListPinnedMessages(ListPinnedMessagesRequest) returns (ListPinnedMessagesResponse);
  422. // Pins a current message. The caller must have room.manage and must be able
  423. // to read the message. Repeating an existing pin is idempotent. Direct-message
  424. // rooms are rejected.
  425. rpc CreatePinnedMessage(CreatePinnedMessageRequest) returns (CreatePinnedMessageResponse);
  426. // Removes a current pin. The caller must have room.manage. Removing a
  427. // missing pin is idempotent. Direct-message rooms are rejected.
  428. rpc DeletePinnedMessage(DeletePinnedMessageRequest) returns (DeletePinnedMessageResponse);
  429. // Refreshes the current user's live-only typing indicator for a room or
  430. // thread. Room membership is required; message posting permission is not.
  431. rpc UpdateTypingIndicator(UpdateTypingIndicatorRequest) returns (UpdateTypingIndicatorResponse);
  432. // Returns one page of room timeline events, including related user data
  433. // needed to render the page. Room membership is required. Channel-room reads
  434. // also require message.read or message.read-interactions. The server returns
  435. // only related thread roots for an interaction-scoped caller. DM membership
  436. // authorizes DM reads.
  437. rpc GetRoomEvents(GetRoomEventsRequest) returns (GetRoomEventsResponse);
  438. // Returns a room timeline window centered around a specific event. Use this to
  439. // open a permalink, search result, or notification target in context. Returns
  440. // NOT_FOUND when the anchor event is missing or not visible in the room
  441. // timeline. Returns PERMISSION_DENIED when room membership or both read modes
  442. // are missing, or when the anchor is in an unrelated thread. DM membership
  443. // authorizes DM reads.
  444. rpc GetRoomEventsAround(GetRoomEventsAroundRequest) returns (GetRoomEventsAroundResponse);
  445. // Marks a room timeline as read through the supplied event. Room membership
  446. // is required. Channel-room reads also require message.read or
  447. // message.read-interactions. DM membership authorizes DM reads. If no event
  448. // is supplied, the server marks through the latest root event that the caller
  449. // can read. Clients
  450. // usually call this after the user has viewed the latest visible event in the
  451. // room.
  452. rpc MarkRoomAsRead(MarkRoomAsReadRequest) returns (MarkRoomAsReadResponse);
  453. // Bans a member from a channel room. Direct-message rooms cannot be moderated
  454. // this way, and the target must currently be a room member.
  455. rpc BanMember(BanMemberRequest) returns (BanMemberResponse);
  456. // Removes an active channel room ban. Calling this when no active ban exists
  457. // is allowed and still returns success.
  458. rpc UnbanMember(UnbanMemberRequest) returns (UnbanMemberResponse);
  459. }