room_timeline.proto 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "chatto/api/v1/message_types.proto";
  5. import "chatto/api/v1/users.proto";
  6. import "google/protobuf/timestamp.proto";
  7. // Related entities included beside timeline/feed events.
  8. //
  9. // Includes are reserved for hot paginated feed paths where many events may
  10. // repeatedly reference the same render data. Other APIs should return resources
  11. // directly and rely on BatchGet-style follow-up hydration instead of adding
  12. // includes maps.
  13. message RoomTimelineIncludes {
  14. // Users keyed by user ID.
  15. map<string, User> users = 1;
  16. }
  17. // Payload for room lifecycle and membership timeline events.
  18. message RoomTimelineRoomEvent {
  19. // Room affected by the event.
  20. string room_id = 1;
  21. }
  22. // Payload for a message-posted timeline event.
  23. message RoomMessagePosted {
  24. // Renderable message created by this timeline event.
  25. Message message = 1;
  26. }
  27. // One event in a room or thread timeline.
  28. //
  29. // Clients should inspect the event oneof to choose the renderer for the event.
  30. message RoomTimelineEvent {
  31. // Stable event ID.
  32. string id = 1;
  33. // Time when the event was created.
  34. google.protobuf.Timestamp created_at = 2;
  35. // User ID of the event actor.
  36. string actor_id = 3;
  37. // Concrete event payload.
  38. oneof event {
  39. // A message was posted.
  40. RoomMessagePosted message_posted = 10;
  41. // The room was created.
  42. RoomTimelineRoomEvent room_created = 20;
  43. // The room metadata was updated.
  44. RoomTimelineRoomEvent room_updated = 21;
  45. // The room was deleted.
  46. RoomTimelineRoomEvent room_deleted = 22;
  47. // The room was archived.
  48. RoomTimelineRoomEvent room_archived = 23;
  49. // The room was unarchived.
  50. RoomTimelineRoomEvent room_unarchived = 24;
  51. // A user joined the room.
  52. RoomTimelineRoomEvent user_joined_room = 30;
  53. // A user left the room.
  54. RoomTimelineRoomEvent user_left_room = 31;
  55. }
  56. }
  57. // Cursor page of room or thread timeline events.
  58. //
  59. // Use opaque start_cursor and end_cursor values with before/after requests to
  60. // continue paging in either direction. Clients must treat cursor values as
  61. // server-owned tokens and must not parse or construct them. The has_older and
  62. // has_newer flags tell clients whether another request can extend the current
  63. // window.
  64. message RoomTimelinePage {
  65. // Events in display order.
  66. repeated RoomTimelineEvent events = 1;
  67. // Opaque cursor for the first event in the page.
  68. string start_cursor = 2;
  69. // Opaque cursor for the last event in the page.
  70. string end_cursor = 3;
  71. // True when older events are available before start_cursor.
  72. bool has_older = 4;
  73. // True when newer events are available after end_cursor.
  74. bool has_newer = 5;
  75. // Hot-path related entities needed to render the page without per-event hydration.
  76. RoomTimelineIncludes includes = 6;
  77. }
  78. // Request for a page of room timeline events.
  79. //
  80. // Omit the cursor to load the initial page. Set before to a previously returned
  81. // start_cursor to page toward older events, or after to a previously returned
  82. // end_cursor to page toward newer events.
  83. message GetRoomEventsRequest {
  84. // Required. Room whose timeline should be loaded.
  85. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  86. // Maximum number of events to return. The server may clamp very large limits.
  87. int32 limit = 2;
  88. // Cursor direction for paging.
  89. oneof cursor {
  90. // Return events older than this opaque cursor.
  91. string before = 3;
  92. // Return events newer than this opaque cursor.
  93. string after = 4;
  94. }
  95. }
  96. // Response containing one room timeline page.
  97. message GetRoomEventsResponse {
  98. // Loaded timeline page.
  99. RoomTimelinePage page = 1;
  100. }
  101. // Request for room timeline events around a specific event.
  102. //
  103. // Use this when a client needs to jump to a known event and render enough
  104. // context around it.
  105. message GetRoomEventsAroundRequest {
  106. // Required. Room whose timeline should be loaded.
  107. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  108. // Required. Anchor event ID that should appear in the returned page.
  109. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  110. // Maximum number of events to return around the anchor.
  111. int32 limit = 3;
  112. }
  113. // Response containing a room timeline window around a specific event.
  114. message GetRoomEventsAroundResponse {
  115. // Loaded timeline page.
  116. RoomTimelinePage page = 1;
  117. // Zero-based index of the anchor event within page.events.
  118. int32 target_index = 2;
  119. }
  120. // Request for a page of events in one thread.
  121. //
  122. // Omit the cursor to load the latest visible part of the thread, including the
  123. // root message. Set before to a previously returned start_cursor to page toward
  124. // older replies, or after to a previously returned end_cursor to page toward
  125. // newer replies without repeating the root message.
  126. message GetThreadEventsRequest {
  127. // Required. Room containing the thread.
  128. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  129. // Required. Event ID of the root message for the thread.
  130. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  131. // Maximum number of events to return. The server may clamp very large limits.
  132. int32 limit = 3;
  133. // Cursor direction for paging.
  134. oneof cursor {
  135. // Return thread events older than this opaque cursor.
  136. string before = 4;
  137. // Return thread events newer than this opaque cursor.
  138. string after = 5;
  139. }
  140. }
  141. // Response containing one thread timeline page.
  142. message GetThreadEventsResponse {
  143. // Loaded timeline page.
  144. RoomTimelinePage page = 1;
  145. }
  146. // Request for thread events around a specific event.
  147. //
  148. // Use this when a client needs to jump to a known reply and render surrounding
  149. // thread context.
  150. message GetThreadEventsAroundRequest {
  151. // Required. Room containing the thread.
  152. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  153. // Required. Event ID of the root message for the thread.
  154. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  155. // Required. Anchor event ID inside the thread. The event should belong to the
  156. // requested thread.
  157. string event_id = 3 [(buf.validate.field).string.min_len = 1];
  158. // Maximum number of events to return around the anchor.
  159. int32 limit = 4;
  160. }
  161. // Response containing a thread timeline window around a specific event.
  162. message GetThreadEventsAroundResponse {
  163. // Loaded timeline page.
  164. RoomTimelinePage page = 1;
  165. // Zero-based index of the anchor event within page.events.
  166. int32 target_index = 2;
  167. }