messages.proto 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. // Existing room-scoped attachment asset IDs to include with the message.
  27. repeated string attachment_asset_ids = 3;
  28. // Event ID of the thread root message when posting a thread reply.
  29. string thread_root_event_id = 4;
  30. // Event ID this message replies to for attribution.
  31. string in_reply_to = 5;
  32. // True to also echo a thread reply into the main room timeline.
  33. bool also_send_to_channel = 6;
  34. // Short-lived token returned by FetchLinkPreview for the selected URL. The
  35. // server resolves the token to cached, server-fetched metadata during post.
  36. string link_preview_token = 10;
  37. }
  38. // Result of creating a message.
  39. message CreateMessageResponse {
  40. // Field 2 was `mention_confirmation`, used by a server-enforced large
  41. // mention confirmation flow before role mention confirmation became a
  42. // client-only composer affordance.
  43. reserved 2;
  44. reserved "mention_confirmation";
  45. // Field 3 was `includes`, used before create responses were narrowed to the
  46. // generated message.
  47. reserved 3;
  48. reserved "includes";
  49. // Renderable message created by the request.
  50. Message message = 1;
  51. }
  52. // Request to patch a message.
  53. message UpdateMessageRequest {
  54. // Required. Room containing the message.
  55. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  56. // Required. Event ID of the message to edit.
  57. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  58. // New message body text. Omit to preserve the current body.
  59. optional string body = 3 [(buf.validate.field).string.max_len = 10000];
  60. // For thread replies, whether a channel echo should exist after saving.
  61. // Omit to preserve the current echo state.
  62. optional bool also_send_to_channel = 4;
  63. }
  64. // Result of editing a message.
  65. message UpdateMessageResponse {
  66. reserved 1;
  67. reserved "updated";
  68. // Field 3 was `includes`, used before update responses were narrowed to the
  69. // edited message.
  70. reserved 3;
  71. reserved "includes";
  72. // Renderable message after the edit.
  73. Message message = 2;
  74. }
  75. // Request to retract a message.
  76. message DeleteMessageRequest {
  77. // Required. Room containing the message.
  78. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  79. // Required. Event ID of the message to retract.
  80. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  81. }
  82. // Result of retracting a message.
  83. message DeleteMessageResponse {
  84. // True when the delete/retract request was accepted.
  85. bool deleted = 1;
  86. }
  87. // Request to remove one attachment from a message.
  88. message DeleteAttachmentRequest {
  89. // Required. Room containing the message.
  90. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  91. // Required. Event ID of the message containing the attachment.
  92. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  93. // Required. Attachment ID to remove from the message.
  94. string attachment_id = 3 [(buf.validate.field).string.min_len = 1];
  95. }
  96. // Result of removing one attachment from a message.
  97. message DeleteAttachmentResponse {
  98. // True when the attachment removal was accepted.
  99. bool deleted = 1;
  100. }
  101. // Request to remove the accepted link preview from a message.
  102. message DeleteLinkPreviewRequest {
  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 link preview.
  106. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  107. // Required. URL of the link preview to remove.
  108. string url = 3 [(buf.validate.field).string.min_len = 1];
  109. }
  110. // Result of removing a link preview from a message.
  111. message DeleteLinkPreviewResponse {
  112. // True when the link preview removal was accepted.
  113. bool deleted = 1;
  114. }
  115. // Request to read one visible message.
  116. message GetMessageRequest {
  117. // Field 3 was `thumbnail`, used before custom attachment URL hydration moved
  118. // to AssetService.
  119. reserved 3;
  120. reserved "thumbnail";
  121. // Required. Room containing the message.
  122. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  123. // Required. Message event ID.
  124. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  125. }
  126. // Response containing one renderable message.
  127. message GetMessageResponse {
  128. // Field 2 was `includes`, used before message read responses were narrowed
  129. // to messages.
  130. reserved 2;
  131. reserved "includes";
  132. // Renderable message.
  133. Message message = 1;
  134. }
  135. // Request to read many visible messages in one room.
  136. message BatchGetMessagesRequest {
  137. // Field 3 was `thumbnail`, used before custom attachment URL hydration moved
  138. // to AssetService.
  139. reserved 3;
  140. reserved "thumbnail";
  141. // Required. Room containing the messages.
  142. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  143. // Required. Message event IDs. Missing, retracted, non-message, and
  144. // wrong-room event IDs are omitted from the response.
  145. repeated string event_ids = 2 [(buf.validate.field).repeated = {
  146. min_items: 1
  147. max_items: 100
  148. items: {
  149. string: {min_len: 1}
  150. }
  151. }];
  152. }
  153. // Response containing renderable messages.
  154. message BatchGetMessagesResponse {
  155. // Field 2 was `includes`, used before message read responses were narrowed
  156. // to messages.
  157. reserved 2;
  158. reserved "includes";
  159. // Renderable messages in first-seen request order.
  160. repeated Message messages = 1;
  161. }
  162. // Creates messages in room and thread timelines.
  163. service MessageService {
  164. // Fetches and caches metadata for a composer URL. Authentication is required
  165. // to avoid exposing the preview fetcher as an unauthenticated network proxy.
  166. // Successful responses include a short-lived token accepted by CreateMessage.
  167. rpc FetchLinkPreview(FetchLinkPreviewRequest) returns (FetchLinkPreviewResponse);
  168. // Creates a message for the current user. The user must be a room member and
  169. // must have message.post for room messages or message.post-in-thread for
  170. // thread replies. Echoing a thread reply also requires message.echo and
  171. // message.post.
  172. rpc CreateMessage(CreateMessageRequest) returns (CreateMessageResponse);
  173. // Edits a message body. Authors can edit their own messages within the edit
  174. // window. Non-authors need message.manage and cannot change channel echo
  175. // state.
  176. rpc UpdateMessage(UpdateMessageRequest) returns (UpdateMessageResponse);
  177. // Retracts a message. Authors can delete their own messages. Non-authors need
  178. // message.manage.
  179. rpc DeleteMessage(DeleteMessageRequest) returns (DeleteMessageResponse);
  180. // Removes one attachment from the author's own message.
  181. rpc DeleteAttachment(DeleteAttachmentRequest) returns (DeleteAttachmentResponse);
  182. // Removes the accepted link preview from the author's own message.
  183. rpc DeleteLinkPreview(DeleteLinkPreviewRequest) returns (DeleteLinkPreviewResponse);
  184. // Reads one renderable message, including current body, attachment metadata,
  185. // link preview, reactions, and thread metadata. Authentication and room
  186. // membership are required. Returns NOT_FOUND when the event does not exist,
  187. // is not a message, has been retracted, or belongs to a different room.
  188. rpc GetMessage(GetMessageRequest) returns (GetMessageResponse);
  189. // Reads many renderable messages in one room. Authentication and room
  190. // membership are required. Missing, retracted, non-message, and wrong-room
  191. // event IDs are omitted. Results preserve first-seen request order and
  192. // repeated event IDs are de-duplicated.
  193. rpc BatchGetMessages(BatchGetMessagesRequest) returns (BatchGetMessagesResponse);
  194. // Adds a reaction to a message. The user must be a room member and have
  195. // message.react in the target room.
  196. rpc AddReaction(AddReactionRequest) returns (AddReactionResponse);
  197. // Removes a reaction from a message. The user must be a room member and have
  198. // message.react in the target room.
  199. rpc RemoveReaction(RemoveReactionRequest) returns (RemoveReactionResponse);
  200. }