viewer.proto 3.1 KB

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