messages.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "chatto/api/v1/link_previews.proto";
  5. import "chatto/api/v1/message_types.proto";
  6. import "chatto/api/v1/reactions.proto";
  7. // Request to create a message in a room or thread.
  8. message CreateMessageRequest {
  9. // Field 8 was `link_preview`, a client-provided metadata message used before
  10. // CreateMessage accepted only server-issued link preview tokens.
  11. reserved 8;
  12. reserved "link_preview";
  13. // Field 9 was `attachments`, inline attachment bytes accepted before
  14. // AssetUploadService moved uploads into a dedicated chunked API.
  15. reserved 9;
  16. reserved "attachments";
  17. // Field 7 was `mention_confirmation_token`, used by a server-enforced large
  18. // mention confirmation flow before role mention confirmation became a
  19. // client-only composer affordance.
  20. reserved 7;
  21. reserved "mention_confirmation_token";
  22. // Required. Room where the message should be created.
  23. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  24. // Message body text. Required unless attachment_asset_ids is non-empty.
  25. string body = 2;
  26. // Completed room-scoped asset IDs uploaded by the caller and not yet attached
  27. // to a message. The server attaches them exclusively and atomically to this
  28. // message. At most 10 IDs may be supplied.
  29. repeated string attachment_asset_ids = 3 [(buf.validate.field).repeated = {
  30. max_items: 10
  31. items: {
  32. string: {
  33. min_len: 1
  34. max_bytes: 15
  35. }
  36. }
  37. }];
  38. // Event ID of the thread root message when posting a thread reply.
  39. string thread_root_event_id = 4;
  40. // Event ID this message replies to for attribution.
  41. string in_reply_to = 5;
  42. // True to also echo a thread reply into the main room timeline.
  43. bool also_send_to_channel = 6;
  44. // Short-lived token returned by FetchLinkPreview for the selected URL. The
  45. // server resolves the token to cached, server-fetched metadata during post.
  46. string link_preview_token = 10;
  47. // True to establish the new root message as a thread immediately. Requires
  48. // both message.post and message.post-in-thread. Channel rooms only; cannot
  49. // be combined with thread_root_event_id.
  50. bool create_thread = 11;
  51. }
  52. // Result of creating a message.
  53. message CreateMessageResponse {
  54. // Field 2 was `mention_confirmation`, used by a server-enforced large
  55. // mention confirmation flow before role mention confirmation became a
  56. // client-only composer affordance.
  57. reserved 2;
  58. reserved "mention_confirmation";
  59. // Field 3 was `includes`, used before create responses were narrowed to the
  60. // generated message.
  61. reserved 3;
  62. reserved "includes";
  63. // Renderable message created by the request.
  64. Message message = 1;
  65. }
  66. // Request to patch a message.
  67. message UpdateMessageRequest {
  68. // Required. Room containing the message.
  69. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  70. // Required. Event ID of the message to edit.
  71. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  72. // New message body text. Omit to preserve the current body.
  73. optional string body = 3 [(buf.validate.field).string.max_len = 10000];
  74. // For thread replies, whether a channel echo should exist after saving.
  75. // Omit to preserve the current echo state.
  76. optional bool also_send_to_channel = 4;
  77. }
  78. // Result of editing a message.
  79. message UpdateMessageResponse {
  80. reserved 1;
  81. reserved "updated";
  82. // Field 3 was `includes`, used before update responses were narrowed to the
  83. // edited message.
  84. reserved 3;
  85. reserved "includes";
  86. // Renderable message after the edit.
  87. Message message = 2;
  88. }
  89. // Request to retract a message.
  90. message DeleteMessageRequest {
  91. // Required. Room containing the message.
  92. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  93. // Required. Event ID of the message to retract.
  94. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  95. }
  96. // Result of retracting a message.
  97. message DeleteMessageResponse {
  98. // True when the delete/retract request was accepted.
  99. bool deleted = 1;
  100. }
  101. // Request to remove one attachment from a message.
  102. message DeleteAttachmentRequest {
  103. // Required. Room containing the message.
  104. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  105. // Required. Event ID of the message containing the attachment.
  106. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  107. // Required. Attachment ID to remove from the message.
  108. string attachment_id = 3 [(buf.validate.field).string.min_len = 1];
  109. }
  110. // Result of removing one attachment from a message.
  111. message DeleteAttachmentResponse {
  112. // True when the attachment removal was accepted.
  113. bool deleted = 1;
  114. }
  115. // Request to remove the accepted link preview from a message.
  116. message DeleteLinkPreviewRequest {
  117. // Required. Room containing the message.
  118. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  119. // Required. Event ID of the message containing the link preview.
  120. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  121. // Required. URL of the link preview to remove.
  122. string url = 3 [(buf.validate.field).string.min_len = 1];
  123. }
  124. // Result of removing a link preview from a message.
  125. message DeleteLinkPreviewResponse {
  126. // True when the link preview removal was accepted.
  127. bool deleted = 1;
  128. }
  129. // Request to read one visible message.
  130. message GetMessageRequest {
  131. // Field 3 was `thumbnail`, used before custom attachment URL hydration moved
  132. // to AssetService.
  133. reserved 3;
  134. reserved "thumbnail";
  135. // Required. Room containing the message.
  136. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  137. // Required. Message event ID.
  138. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  139. }
  140. // Response containing one renderable message.
  141. message GetMessageResponse {
  142. // Field 2 was `includes`, used before message read responses were narrowed
  143. // to messages.
  144. reserved 2;
  145. reserved "includes";
  146. // Renderable message.
  147. Message message = 1;
  148. }
  149. // Request to read many visible messages in one room.
  150. message BatchGetMessagesRequest {
  151. // Field 3 was `thumbnail`, used before custom attachment URL hydration moved
  152. // to AssetService.
  153. reserved 3;
  154. reserved "thumbnail";
  155. // Required. Room containing the messages.
  156. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  157. // Required. Message event IDs. Missing, retracted, non-message, and
  158. // wrong-room event IDs are omitted from the response.
  159. repeated string event_ids = 2 [(buf.validate.field).repeated = {
  160. min_items: 1
  161. max_items: 100
  162. items: {
  163. string: {min_len: 1}
  164. }
  165. }];
  166. }
  167. // Response containing renderable messages.
  168. message BatchGetMessagesResponse {
  169. // Field 2 was `includes`, used before message read responses were narrowed
  170. // to messages.
  171. reserved 2;
  172. reserved "includes";
  173. // Renderable messages in first-seen request order.
  174. repeated Message messages = 1;
  175. }
  176. // Creates messages in room and thread timelines.
  177. service MessageService {
  178. // Fetches and caches metadata for a composer URL. Authentication is required
  179. // to avoid exposing the preview fetcher as an unauthenticated network proxy.
  180. // Successful responses include a short-lived token accepted by CreateMessage.
  181. rpc FetchLinkPreview(FetchLinkPreviewRequest) returns (FetchLinkPreviewResponse);
  182. // Creates a message for the current user. The user must be a room member and
  183. // must have message.post for room messages or message.post-in-thread for
  184. // thread replies. Echoing a thread reply also requires message.echo and
  185. // message.post. The room's Threading Mode may automatically establish a root
  186. // thread or reject a thread placement that the mode does not allow.
  187. rpc CreateMessage(CreateMessageRequest) returns (CreateMessageResponse);
  188. // Edits a message body. Authors can edit their own messages within the edit
  189. // window. Non-authors need message.manage and cannot change channel echo
  190. // state. Disabled rooms reject creation of a new channel echo while allowing
  191. // an existing echo to be removed. Room membership is also required.
  192. // Channel-room edits require message.read or a matching thread relationship
  193. // with message.read-interactions. DM membership authorizes the DM read.
  194. rpc UpdateMessage(UpdateMessageRequest) returns (UpdateMessageResponse);
  195. // Retracts a message. Authors can delete their own messages. Non-authors need
  196. // message.manage.
  197. rpc DeleteMessage(DeleteMessageRequest) returns (DeleteMessageResponse);
  198. // Removes one attachment from the author's own message.
  199. rpc DeleteAttachment(DeleteAttachmentRequest) returns (DeleteAttachmentResponse);
  200. // Removes the accepted link preview from the author's own message.
  201. rpc DeleteLinkPreview(DeleteLinkPreviewRequest) returns (DeleteLinkPreviewResponse);
  202. // Reads one renderable message, including current body, attachment metadata,
  203. // link preview, reactions, thread metadata, and pin state. Authentication
  204. // and room membership are required. Channel-room reads also require
  205. // message.read or a matching thread relationship with
  206. // message.read-interactions. DM membership authorizes DM reads. Returns
  207. // NOT_FOUND when the event does not exist, is not a message, has been
  208. // retracted, or belongs to a different room.
  209. rpc GetMessage(GetMessageRequest) returns (GetMessageResponse);
  210. // Reads many renderable messages and their current pin state in one room.
  211. // Authentication and room membership are required. Channel-room reads also
  212. // require message.read or a matching thread relationship with
  213. // message.read-interactions. DM membership authorizes DM reads. Missing,
  214. // retracted, non-message, wrong-room, and inaccessible event IDs are omitted.
  215. // Results preserve first-seen request order, and repeated event IDs are
  216. // de-duplicated.
  217. rpc BatchGetMessages(BatchGetMessagesRequest) returns (BatchGetMessagesResponse);
  218. // Adds a reaction to a message. The user must be a room member and have
  219. // message.react. Channel-room reactions also require message.read or a
  220. // matching thread relationship with message.read-interactions. DM membership
  221. // authorizes the DM read.
  222. rpc AddReaction(AddReactionRequest) returns (AddReactionResponse);
  223. // Removes a reaction from a message. The user must be a room member and have
  224. // message.react. Channel-room reactions also require message.read or a
  225. // matching thread relationship with message.read-interactions. DM membership
  226. // authorizes the DM read.
  227. rpc RemoveReaction(RemoveReactionRequest) returns (RemoveReactionResponse);
  228. }