viewer.proto 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "chatto/api/v1/permissions.proto";
  4. import "chatto/api/v1/users.proto";
  5. import "google/protobuf/timestamp.proto";
  6. // User preference for rendering times in clients.
  7. enum TimeFormat {
  8. // No explicit preference was stored.
  9. TIME_FORMAT_UNSPECIFIED = 0;
  10. // Let the client choose based on locale and browser settings.
  11. TIME_FORMAT_AUTO = 1;
  12. // Render times using a 12-hour clock.
  13. TIME_FORMAT_12_HOUR = 2;
  14. // Render times using a 24-hour clock.
  15. TIME_FORMAT_24_HOUR = 3;
  16. }
  17. // Server-level display settings for the authenticated user.
  18. message UserSettings {
  19. // Optional IANA timezone override. Absent means no choice has been recorded.
  20. // Empty means the user explicitly chose the browser's local timezone.
  21. // Both use browser-local time; only absence permits automatic device reporting.
  22. optional string timezone = 1;
  23. // Preferred time format.
  24. TimeFormat time_format = 2;
  25. // Whether the stored time zone may appear on the user's public profile.
  26. // New servers always set this field. Its absence means the server does not
  27. // support private time zones and may publish any stored time zone.
  28. optional bool share_timezone = 3;
  29. }
  30. // Current authenticated user's public profile plus self-only settings.
  31. message ViewerUser {
  32. reserved 1 to 6;
  33. reserved "id", "login", "display_name", "avatar_url", "custom_status", "presence_status";
  34. // Whether the account has at least one verified email address.
  35. bool has_verified_email = 7;
  36. // Current user's display settings.
  37. UserSettings settings = 8;
  38. // Whether the authenticated user may delete this account.
  39. bool viewer_can_delete_account = 9;
  40. // Last time a login credential changed, when known.
  41. google.protobuf.Timestamp last_login_change = 10;
  42. // Public user fields for the authenticated user.
  43. User profile = 11;
  44. // Whether this account currently has a password sign-in credential.
  45. bool has_password = 12;
  46. }
  47. // Permission-derived capabilities for the authenticated user.
  48. message ViewerCapabilities {
  49. // Keyed capability decisions for the authenticated user.
  50. repeated CapabilityGrant grants = 1;
  51. // Whether the user has unread followed threads.
  52. bool has_unread_followed_threads = 2;
  53. }
  54. // Effective server/channel permission decisions for the authenticated user.
  55. message ServerViewerPermissions {
  56. // One row per permission known to the server.
  57. repeated PermissionGrant permissions = 1;
  58. }
  59. // Non-permission server state for the authenticated user.
  60. message ServerViewerState {
  61. // Whether any joined channel room has neutral Badge attention.
  62. bool has_unread_rooms = 1;
  63. }
  64. // State of explicit privileged-mode activation for this authenticated session.
  65. message PrivilegedModeState {
  66. // Whether the user has an elevation-required permission entitlement. This
  67. // includes owner entitlement and explicit allows at any supported scope.
  68. bool available = 1;
  69. // Whether elevated permissions are effective for this session now.
  70. bool active = 2;
  71. // Absolute activation deadline. Present only while privileged mode is active.
  72. google.protobuf.Timestamp expires_at = 3;
  73. }
  74. // Request for the authenticated viewer snapshot.
  75. message GetViewerRequest {}
  76. // Authenticated viewer snapshot needed by application shells.
  77. message GetViewerResponse {
  78. reserved 3, 4;
  79. reserved "server_notification_preference", "room_notification_preferences";
  80. // Current authenticated user.
  81. ViewerUser user = 1;
  82. // Permission-derived capabilities.
  83. ViewerCapabilities capabilities = 2;
  84. // Effective server/channel permission decisions for the authenticated user.
  85. ServerViewerPermissions viewer_permissions = 5;
  86. // Non-permission server state for the authenticated user.
  87. ServerViewerState viewer_state = 6;
  88. // Explicit privilege activation state for this authenticated session.
  89. PrivilegedModeState privileged_mode = 7;
  90. }
  91. // Request to activate all currently entitled elevation-required permissions.
  92. message ActivatePrivilegedModeRequest {}
  93. // Result of activating privileged mode for the current session.
  94. message ActivatePrivilegedModeResponse {
  95. // Current privileged-mode state after activation.
  96. PrivilegedModeState privileged_mode = 1;
  97. // Permission-derived capabilities that are effective after activation.
  98. ViewerCapabilities capabilities = 2;
  99. // Effective server permission decisions after activation.
  100. ServerViewerPermissions viewer_permissions = 3;
  101. }
  102. // Request to deactivate all elevation-required permissions for this session.
  103. message DeactivatePrivilegedModeRequest {}
  104. // Result of deactivating privileged mode for the current session.
  105. message DeactivatePrivilegedModeResponse {
  106. // Current privileged-mode state after deactivation.
  107. PrivilegedModeState privileged_mode = 1;
  108. // Permission-derived capabilities that are effective after deactivation.
  109. ViewerCapabilities capabilities = 2;
  110. // Effective server permission decisions after deactivation.
  111. ServerViewerPermissions viewer_permissions = 3;
  112. }
  113. // Provides authenticated user profile, preferences, and capability state.
  114. service ViewerService {
  115. // Returns the current authenticated viewer. This RPC requires a logged-in
  116. // user; unauthenticated callers receive an UNAUTHENTICATED error.
  117. rpc GetViewer(GetViewerRequest) returns (GetViewerResponse);
  118. // Activates elevation-required permissions for a fixed, non-sliding window.
  119. // Returns FAILED_PRECONDITION when the caller is a bot or has no eligible
  120. // permission entitlement.
  121. rpc ActivatePrivilegedMode(ActivatePrivilegedModeRequest) returns (ActivatePrivilegedModeResponse);
  122. // Deactivates elevation-required permissions immediately. Returns
  123. // FAILED_PRECONDITION when the caller is a bot.
  124. rpc DeactivatePrivilegedMode(DeactivatePrivilegedModeRequest) returns (DeactivatePrivilegedModeResponse);
  125. }