room_timeline.proto 7.5 KB

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