room_timeline.proto 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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, construct, share between users, or
  62. // reuse them for another room or thread. The server binds each cursor to the
  63. // authenticated viewer and exact timeline resource. The has_older and
  64. // has_newer flags tell clients whether another request can extend the current
  65. // window.
  66. message RoomTimelinePage {
  67. // Events in display order.
  68. repeated RoomTimelineEvent events = 1;
  69. // Opaque cursor for the first event in the page.
  70. string start_cursor = 2;
  71. // Opaque cursor for the last event in the page.
  72. string end_cursor = 3;
  73. // True when older events are available before start_cursor.
  74. bool has_older = 4;
  75. // True when newer events are available after end_cursor.
  76. bool has_newer = 5;
  77. // Hot-path related entities needed to render the page without per-event hydration.
  78. RoomTimelineIncludes includes = 6;
  79. }
  80. // Request for a page of room timeline events.
  81. //
  82. // Omit the cursor to load the initial page. Set before to a previously returned
  83. // start_cursor to page toward older events, or after to a previously returned
  84. // end_cursor to page toward newer events.
  85. message GetRoomEventsRequest {
  86. // Required. Room whose timeline should be loaded.
  87. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  88. // Maximum number of events to return. The server may clamp very large limits.
  89. int32 limit = 2;
  90. // Cursor direction for paging.
  91. oneof cursor {
  92. // Return events older than this opaque cursor.
  93. string before = 3;
  94. // Return events newer than this opaque cursor.
  95. string after = 4;
  96. }
  97. }
  98. // Response containing one room timeline page.
  99. message GetRoomEventsResponse {
  100. // Loaded timeline page.
  101. RoomTimelinePage page = 1;
  102. }
  103. // Request for room timeline events around a specific event.
  104. //
  105. // Use this when a client needs to jump to a known event and render enough
  106. // context around it.
  107. message GetRoomEventsAroundRequest {
  108. // Required. Room whose timeline should be loaded.
  109. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  110. // Required. Anchor event ID that should appear in the returned page.
  111. string event_id = 2 [(buf.validate.field).string.min_len = 1];
  112. // Maximum number of events to return around the anchor.
  113. int32 limit = 3;
  114. }
  115. // Response containing a room timeline window around a specific event.
  116. message GetRoomEventsAroundResponse {
  117. // Loaded timeline page.
  118. RoomTimelinePage page = 1;
  119. // Zero-based index of the anchor event within page.events.
  120. int32 target_index = 2;
  121. }
  122. // Request for a page of events in one thread.
  123. //
  124. // Omit the cursor to load the latest visible part of the thread, including the
  125. // root message. Set before to a previously returned start_cursor to page toward
  126. // older replies, or after to a previously returned end_cursor to page toward
  127. // newer replies without repeating the root message.
  128. message GetThreadEventsRequest {
  129. // Required. Room containing the thread.
  130. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  131. // Required. Event ID of the root message for the thread.
  132. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  133. // Maximum number of events to return. The server may clamp very large limits.
  134. int32 limit = 3;
  135. // Cursor direction for paging.
  136. oneof cursor {
  137. // Return thread events older than this opaque cursor.
  138. string before = 4;
  139. // Return thread events newer than this opaque cursor.
  140. string after = 5;
  141. }
  142. }
  143. // Response containing one thread timeline page.
  144. message GetThreadEventsResponse {
  145. // Loaded timeline page.
  146. RoomTimelinePage page = 1;
  147. }
  148. // Request for thread events around a specific event.
  149. //
  150. // Use this when a client needs to jump to a known reply and render surrounding
  151. // thread context.
  152. message GetThreadEventsAroundRequest {
  153. // Required. Room containing the thread.
  154. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  155. // Required. Event ID of the root message for the thread.
  156. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  157. // Required. Anchor event ID inside the thread. The event should belong to the
  158. // requested thread.
  159. string event_id = 3 [(buf.validate.field).string.min_len = 1];
  160. // Maximum number of events to return around the anchor.
  161. int32 limit = 4;
  162. }
  163. // Response containing a thread timeline window around a specific event.
  164. message GetThreadEventsAroundResponse {
  165. // Loaded timeline page.
  166. RoomTimelinePage page = 1;
  167. // Zero-based index of the anchor event within page.events.
  168. int32 target_index = 2;
  169. }