viewer.proto 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 the client should use the
  20. // browser's local timezone.
  21. optional string timezone = 1;
  22. // Preferred time format.
  23. TimeFormat time_format = 2;
  24. // Whether the stored time zone may appear on the user's public profile.
  25. // New servers always set this field. Its absence means the server does not
  26. // support private time zones and may publish any stored time zone.
  27. optional bool share_timezone = 3;
  28. }
  29. // Current authenticated user's public profile plus self-only settings.
  30. message ViewerUser {
  31. reserved 1 to 6;
  32. reserved "id", "login", "display_name", "avatar_url", "custom_status", "presence_status";
  33. // Whether the account has at least one verified email address.
  34. bool has_verified_email = 7;
  35. // Current user's display settings.
  36. UserSettings settings = 8;
  37. // Whether the authenticated user may delete this account.
  38. bool viewer_can_delete_account = 9;
  39. // Last time a login credential changed, when known.
  40. google.protobuf.Timestamp last_login_change = 10;
  41. // Public user fields for the authenticated user.
  42. User profile = 11;
  43. // Whether this account currently has a password sign-in credential.
  44. bool has_password = 12;
  45. }
  46. // Permission-derived capabilities for the authenticated user.
  47. message ViewerCapabilities {
  48. // Keyed capability decisions for the authenticated user.
  49. repeated CapabilityGrant grants = 1;
  50. // Whether the user has unread followed threads.
  51. bool has_unread_followed_threads = 2;
  52. }
  53. // Effective server/channel permission decisions for the authenticated user.
  54. message ServerViewerPermissions {
  55. // One row per permission known to the server.
  56. repeated PermissionGrant permissions = 1;
  57. }
  58. // Non-permission server state for the authenticated user.
  59. message ServerViewerState {
  60. // Whether any joined channel room has neutral Badge attention.
  61. bool has_unread_rooms = 1;
  62. }
  63. // Request for the authenticated viewer snapshot.
  64. message GetViewerRequest {}
  65. // Authenticated viewer snapshot needed by application shells.
  66. message GetViewerResponse {
  67. reserved 3, 4;
  68. reserved "server_notification_preference", "room_notification_preferences";
  69. // Current authenticated user.
  70. ViewerUser user = 1;
  71. // Permission-derived capabilities.
  72. ViewerCapabilities capabilities = 2;
  73. // Effective server/channel permission decisions for the authenticated user.
  74. ServerViewerPermissions viewer_permissions = 5;
  75. // Non-permission server state for the authenticated user.
  76. ServerViewerState viewer_state = 6;
  77. }
  78. // Provides authenticated user profile, preferences, and capability state.
  79. service ViewerService {
  80. // Returns the current authenticated viewer. This RPC requires a logged-in
  81. // user; unauthenticated callers receive an UNAUTHENTICATED error.
  82. rpc GetViewer(GetViewerRequest) returns (GetViewerResponse);
  83. }