read_state.proto 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "google/protobuf/timestamp.proto";
  5. // Request to mark a room timeline as read.
  6. message MarkRoomAsReadRequest {
  7. // Required. Room whose timeline should be marked read.
  8. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  9. // Highest room event ID the current user has read. When set, the event must
  10. // exist as a root event in the room timeline. Leave empty to mark through the
  11. // room's current latest root event.
  12. string up_to_event_id = 2;
  13. }
  14. // Result of marking a room timeline as read.
  15. //
  16. // Clients can use the previous timestamp to place a local New messages
  17. // separator. Notification policy controls room Badge attention separately.
  18. message MarkRoomAsReadResponse {
  19. // New room read timestamp stored for the current user.
  20. google.protobuf.Timestamp last_read_at = 1;
  21. // Previous room read timestamp, when one existed.
  22. google.protobuf.Timestamp previous_last_read_at = 2;
  23. }
  24. // Request to mark a message thread as read.
  25. message MarkThreadAsReadRequest {
  26. // Required. Room containing the thread.
  27. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  28. // Required. Event ID of the root message for the thread.
  29. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  30. // Highest thread event ID the current user has read. The event should belong
  31. // to the thread identified by thread_root_event_id.
  32. string up_to_event_id = 3;
  33. }
  34. // Result of marking a message thread as read.
  35. message MarkThreadAsReadResponse {
  36. reserved "previous_read_at";
  37. // Previous thread read timestamp, when one existed.
  38. google.protobuf.Timestamp previous_last_read_at = 1;
  39. // Resulting thread read timestamp. A stale request retains the newer marker.
  40. // Absent when no marker exists.
  41. google.protobuf.Timestamp last_read_at = 2;
  42. }
  43. // Current stored read position. Its event can later be retracted. The timestamp
  44. // is absent if the event can no longer be resolved. This is not Badge attention.
  45. message ReadMarker {
  46. // Last-read event ID, to locate the boundary in a timeline.
  47. string last_read_event_id = 1;
  48. // Creation time of the last-read event, when available.
  49. google.protobuf.Timestamp last_read_at = 2;
  50. }
  51. // Current viewer's stored room read state.
  52. message RoomReadState {
  53. // Room ID.
  54. string room_id = 1;
  55. // Absent when no non-empty marker has been stored. Reading never initializes it.
  56. ReadMarker marker = 2;
  57. }
  58. // Current viewer's stored thread read state.
  59. message ThreadReadState {
  60. // Room ID.
  61. string room_id = 1;
  62. // Root message ID.
  63. string thread_root_event_id = 2;
  64. // Absent when no non-empty marker has been stored. Reading never advances it.
  65. ReadMarker marker = 3;
  66. }
  67. // Request current room read state without changing it.
  68. message GetRoomReadStateRequest {
  69. // Room ID.
  70. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  71. }
  72. // Current room read state, including an absent marker when none is stored.
  73. message GetRoomReadStateResponse {
  74. // State for the requested room and viewer.
  75. RoomReadState state = 1;
  76. }
  77. // Request room read states. Duplicates are removed in first-seen order.
  78. message BatchGetRoomReadStatesRequest {
  79. // Up to 100 room IDs. Missing or inaccessible rooms are omitted.
  80. repeated string room_ids = 1 [(buf.validate.field).repeated = {
  81. min_items: 1, max_items: 100, items: {string: {min_len: 1}}
  82. }];
  83. }
  84. // Accessible room read states in first-seen request order.
  85. message BatchGetRoomReadStatesResponse {
  86. // States for the current viewer. An absent marker does not omit the state.
  87. repeated RoomReadState states = 1;
  88. }
  89. // Request current thread read state without changing it.
  90. message GetThreadReadStateRequest {
  91. // Room ID.
  92. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  93. // Root message ID.
  94. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  95. }
  96. // Current thread read state.
  97. message GetThreadReadStateResponse {
  98. // State for the requested thread and viewer.
  99. ThreadReadState state = 1;
  100. }
  101. // Request thread read states. Duplicates are removed in first-seen order.
  102. message BatchGetThreadReadStatesRequest {
  103. // Up to 100 room/thread targets. Missing or inaccessible targets are omitted.
  104. repeated ThreadReadStateTarget targets = 1 [(buf.validate.field).repeated = {min_items: 1, max_items: 100}];
  105. }
  106. // Accessible thread read states in first-seen request order.
  107. message BatchGetThreadReadStatesResponse {
  108. // States for the current viewer. An absent marker does not omit the state.
  109. repeated ThreadReadState states = 1;
  110. }
  111. // Room and root identity for one thread read state.
  112. message ThreadReadStateTarget {
  113. // Room ID.
  114. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  115. // Root message ID.
  116. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  117. }