viewer.proto 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "chatto/api/v1/notification_preferences.proto";
  4. import "chatto/api/v1/permissions.proto";
  5. import "chatto/api/v1/users.proto";
  6. import "google/protobuf/timestamp.proto";
  7. // User preference for rendering times in clients.
  8. enum TimeFormat {
  9. // No explicit preference was stored.
  10. TIME_FORMAT_UNSPECIFIED = 0;
  11. // Let the client choose based on locale and browser settings.
  12. TIME_FORMAT_AUTO = 1;
  13. // Render times using a 12-hour clock.
  14. TIME_FORMAT_12_HOUR = 2;
  15. // Render times using a 24-hour clock.
  16. TIME_FORMAT_24_HOUR = 3;
  17. }
  18. // Server-level display settings for the authenticated user.
  19. message UserSettings {
  20. // Optional IANA timezone override. Absent means the client should use the
  21. // browser's local timezone.
  22. optional string timezone = 1;
  23. // Preferred time format.
  24. TimeFormat time_format = 2;
  25. }
  26. // Current authenticated user's public profile plus self-only settings.
  27. message ViewerUser {
  28. reserved 1 to 6;
  29. reserved "id", "login", "display_name", "avatar_url", "custom_status", "presence_status";
  30. // Whether the account has at least one verified email address.
  31. bool has_verified_email = 7;
  32. // Current user's display settings.
  33. UserSettings settings = 8;
  34. // Whether the authenticated user may delete this account.
  35. bool viewer_can_delete_account = 9;
  36. // Last time a login credential changed, when known.
  37. google.protobuf.Timestamp last_login_change = 10;
  38. // Public user fields for the authenticated user.
  39. User profile = 11;
  40. // Whether this account currently has a password sign-in credential.
  41. bool has_password = 12;
  42. }
  43. // Permission-derived capabilities for the authenticated user.
  44. message ViewerCapabilities {
  45. // Keyed capability decisions for the authenticated user.
  46. repeated CapabilityGrant grants = 1;
  47. // Whether the user has unread followed threads.
  48. bool has_unread_followed_threads = 2;
  49. }
  50. // Effective server/channel permission decisions for the authenticated user.
  51. message ServerViewerPermissions {
  52. // One row per permission known to the server.
  53. repeated PermissionGrant permissions = 1;
  54. }
  55. // Non-permission server state for the authenticated user.
  56. message ServerViewerState {
  57. // Whether any joined channel room has unread messages.
  58. bool has_unread_rooms = 1;
  59. }
  60. // Room notification preference for one joined room.
  61. message RoomNotificationPreference {
  62. reserved 2, 3;
  63. reserved "level", "effective_level";
  64. // Room whose preference is represented.
  65. string room_id = 1;
  66. // Stored and effective notification preference.
  67. NotificationPreference preference = 4;
  68. }
  69. // Request for the authenticated viewer snapshot.
  70. message GetViewerRequest {}
  71. // Authenticated viewer snapshot needed by application shells.
  72. message GetViewerResponse {
  73. // Current authenticated user.
  74. ViewerUser user = 1;
  75. // Permission-derived capabilities.
  76. ViewerCapabilities capabilities = 2;
  77. // Server-wide notification preference.
  78. NotificationPreference server_notification_preference = 3;
  79. // Notification preferences for rooms the user participates in.
  80. repeated RoomNotificationPreference room_notification_preferences = 4;
  81. // Effective server/channel permission decisions for the authenticated user.
  82. ServerViewerPermissions viewer_permissions = 5;
  83. // Non-permission server state for the authenticated user.
  84. ServerViewerState viewer_state = 6;
  85. }
  86. // Provides authenticated user profile, preferences, and capability state.
  87. service ViewerService {
  88. // Returns the current authenticated viewer. This RPC requires a logged-in
  89. // user; unauthenticated callers receive an UNAUTHENTICATED error.
  90. rpc GetViewer(GetViewerRequest) returns (GetViewerResponse);
  91. }