threads.proto 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 in rooms where the current user is a member.
  79. // Channel-room threads also require message.read or an active relationship
  80. // with message.read-interactions. Historical DM threads use DM membership.
  81. // The result includes enough root-message data for clients to render the
  82. // list without extra per-field fetches.
  83. rpc ListFollowedThreads(ListFollowedThreadsRequest) returns (ListFollowedThreadsResponse);
  84. // Follows a thread for the current user. Room membership plus message.read or
  85. // an active relationship with message.read-interactions are required. DMs do
  86. // not support current thread actions.
  87. // Followed threads can be surfaced in clients and can participate in thread
  88. // notification behavior.
  89. rpc FollowThread(FollowThreadRequest) returns (FollowThreadResponse);
  90. // Stops following a thread for the current user. Room membership plus
  91. // message.read or an active relationship with message.read-interactions are
  92. // required. DMs do not support current thread actions. The response reports
  93. // the resulting follow state so clients can update local UI immediately.
  94. rpc UnfollowThread(UnfollowThreadRequest) returns (UnfollowThreadResponse);
  95. // Returns one page of events in a message thread. Room membership is
  96. // required. Channel-room reads also require message.read or an active
  97. // relationship with message.read-interactions. Historical DM threads use DM
  98. // membership. Initial pages include the thread root message; cursor pages
  99. // return replies in the requested direction.
  100. rpc GetThreadEvents(GetThreadEventsRequest) returns (GetThreadEventsResponse);
  101. // Returns a thread timeline window centered around a specific event. Use this
  102. // to open a reply from a notification or search result in context. Returns
  103. // NOT_FOUND when the thread root or anchor event is missing or hidden.
  104. // Returns PERMISSION_DENIED when room membership is missing, both read modes
  105. // are missing, or an interaction-scoped account has no relationship with the
  106. // thread. Historical DM threads use DM membership.
  107. rpc GetThreadEventsAround(GetThreadEventsAroundRequest) returns (GetThreadEventsAroundResponse);
  108. // Marks a thread timeline as read through the supplied event without changing
  109. // the room-level read marker. Room membership plus message.read or an active
  110. // relationship with message.read-interactions are required. DMs do not
  111. // support current thread actions.
  112. rpc MarkThreadAsRead(MarkThreadAsReadRequest) returns (MarkThreadAsReadResponse);
  113. }