threads.proto 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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/pagination.proto";
  6. import "chatto/api/v1/read_state.proto";
  7. import "chatto/api/v1/room_timeline.proto";
  8. import "chatto/api/v1/rooms.proto";
  9. // Current follow state for one thread and viewer.
  10. message ThreadFollowState {
  11. // Room containing the thread.
  12. string room_id = 1;
  13. // Event ID of the root message for the thread.
  14. string thread_root_event_id = 2;
  15. // True when the current user follows the thread.
  16. bool following = 3;
  17. }
  18. // Request to follow one message thread.
  19. message FollowThreadRequest {
  20. // Required. Room containing the thread.
  21. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  22. // Required. Event ID of the root message for the thread.
  23. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  24. }
  25. // Result of following a thread.
  26. message FollowThreadResponse {
  27. // True when the current user follows the thread after the operation.
  28. bool following = 1;
  29. // Current follow state after the operation.
  30. ThreadFollowState state = 2;
  31. }
  32. // Request to stop following one message thread.
  33. message UnfollowThreadRequest {
  34. // Required. Room containing the thread.
  35. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  36. // Required. Event ID of the root message for the thread.
  37. string thread_root_event_id = 2 [(buf.validate.field).string.min_len = 1];
  38. }
  39. // Result of unfollowing a thread.
  40. message UnfollowThreadResponse {
  41. // True when the current user follows the thread after the operation.
  42. bool following = 1;
  43. // Current follow state after the operation.
  44. ThreadFollowState state = 2;
  45. }
  46. // One followed thread for the current user.
  47. message FollowedThread {
  48. reserved 1 to 3, 5 to 7;
  49. reserved "room_id", "room_name", "thread_root_event_id", "reply_count", "last_reply_at", "has_unread";
  50. // Renderable root message, when the root is still visible.
  51. Message root_message = 4;
  52. // Room containing the thread.
  53. RoomSummary room = 8;
  54. // Aggregated thread state.
  55. ThreadSummary thread = 9;
  56. }
  57. // Request for a page of followed threads for the current user.
  58. message ListFollowedThreadsRequest {
  59. reserved 1, 2;
  60. reserved "limit", "offset";
  61. // Page request. Defaults to 20 results when absent or limit is zero.
  62. PageRequest page = 3;
  63. }
  64. // Response containing one followed-thread page.
  65. message ListFollowedThreadsResponse {
  66. reserved 2, 3;
  67. reserved "total_count", "has_more";
  68. // Followed threads in newest-activity-first order.
  69. repeated FollowedThread threads = 1;
  70. // Hot-path related entities needed to render this feed page without
  71. // per-thread hydration.
  72. RoomTimelineIncludes includes = 4;
  73. // Page metadata.
  74. PageInfo page = 5;
  75. }
  76. // Manages thread follow state for the current user.
  77. service ThreadService {
  78. // Returns followed threads for the current user, including enough root-message
  79. // data for clients to render the list without extra per-field fetches.
  80. rpc ListFollowedThreads(ListFollowedThreadsRequest) returns (ListFollowedThreadsResponse);
  81. // Follows a thread for the current user. Followed threads can be surfaced in
  82. // clients and can participate in thread notification behavior.
  83. rpc FollowThread(FollowThreadRequest) returns (FollowThreadResponse);
  84. // Stops following a thread for the current user. The response reports the
  85. // resulting follow state so clients can update local UI immediately.
  86. rpc UnfollowThread(UnfollowThreadRequest) returns (UnfollowThreadResponse);
  87. // Returns one page of events in a message thread. Initial pages include the
  88. // thread root message; cursor pages return replies in the requested direction.
  89. rpc GetThreadEvents(GetThreadEventsRequest) returns (GetThreadEventsResponse);
  90. // Returns a thread timeline window centered around a specific event. Use this
  91. // to open a reply from a notification or search result in context. Returns
  92. // NOT_FOUND when the thread root or anchor event is missing or hidden and
  93. // PERMISSION_DENIED when the room is inaccessible.
  94. rpc GetThreadEventsAround(GetThreadEventsAroundRequest) returns (GetThreadEventsAroundResponse);
  95. // Marks a thread timeline as read through the supplied event without changing
  96. // the room-level read marker.
  97. rpc MarkThreadAsRead(MarkThreadAsReadRequest) returns (MarkThreadAsReadResponse);
  98. }