notification_preferences.proto 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. // Notification delivery level for a room.
  5. enum NotificationLevel {
  6. // The level was not specified.
  7. NOTIFICATION_LEVEL_UNSPECIFIED = 0;
  8. // Use the inherited default for the room.
  9. NOTIFICATION_LEVEL_DEFAULT = 1;
  10. // Do not notify for this room.
  11. NOTIFICATION_LEVEL_MUTED = 2;
  12. // Notify according to the normal room rules.
  13. NOTIFICATION_LEVEL_NORMAL = 3;
  14. // Notify for every message in the room.
  15. NOTIFICATION_LEVEL_ALL_MESSAGES = 4;
  16. }
  17. // Stored and effective notification preference.
  18. message NotificationPreference {
  19. // Explicit level stored for the current user.
  20. NotificationLevel level = 1;
  21. // Level after applying defaults and inheritance.
  22. NotificationLevel effective_level = 2;
  23. }
  24. // Current notification preference.
  25. message GetNotificationPreferenceResponse {
  26. // Field 1 was `level` and field 2 was `effective_level` before the shared
  27. // NotificationPreference shape.
  28. reserved 1, 2;
  29. reserved "level", "effective_level";
  30. // Current stored and effective notification preference.
  31. NotificationPreference preference = 3;
  32. }
  33. // Updated notification preference.
  34. message UpdateNotificationPreferenceResponse {
  35. // Field 1 was `level` and field 2 was `effective_level` before the shared
  36. // NotificationPreference shape.
  37. reserved 1, 2;
  38. reserved "level", "effective_level";
  39. // Stored and effective notification preference after the update.
  40. NotificationPreference preference = 3;
  41. }
  42. // Request for the current user's server-level notification preference.
  43. message GetServerNotificationPreferenceRequest {}
  44. // Request to update the current user's server-level notification level.
  45. message UpdateServerNotificationPreferenceRequest {
  46. // Required. New explicit notification level. Use NOTIFICATION_LEVEL_DEFAULT
  47. // to return the server to default behavior.
  48. NotificationLevel level = 1 [(buf.validate.field).enum = {
  49. defined_only: true
  50. not_in: [0]
  51. }];
  52. }
  53. // Request for the current user's notification preference in one room.
  54. message GetRoomNotificationPreferenceRequest {
  55. // Required. Room whose notification preference should be loaded for the current user.
  56. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  57. }
  58. // Request to update the current user's notification level in one room.
  59. message UpdateRoomNotificationPreferenceRequest {
  60. // Required. Room whose notification level should be changed for the current user.
  61. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  62. // Required. New explicit notification level. Use NOTIFICATION_LEVEL_DEFAULT
  63. // to return the room to inherited/default behavior.
  64. NotificationLevel level = 2 [(buf.validate.field).enum = {
  65. defined_only: true
  66. not_in: [0]
  67. }];
  68. }
  69. // Reads and updates per-room notification preferences for the current user.
  70. service NotificationPreferencesService {
  71. // Returns the current user's explicit and effective server notification level.
  72. rpc GetServerNotificationPreference(GetServerNotificationPreferenceRequest) returns (GetNotificationPreferenceResponse);
  73. // Updates the current user's explicit server notification level and returns the
  74. // resulting stored and effective levels.
  75. rpc UpdateServerNotificationPreference(UpdateServerNotificationPreferenceRequest) returns (UpdateNotificationPreferenceResponse);
  76. // Returns the current user's explicit and effective notification level for a
  77. // room. Use this before rendering room notification controls so the UI can
  78. // distinguish inherited defaults from an explicit room override. Returns
  79. // NOT_FOUND when the room does not exist and PERMISSION_DENIED when the room
  80. // exists but is inaccessible to the caller.
  81. rpc GetRoomNotificationPreference(GetRoomNotificationPreferenceRequest) returns (GetNotificationPreferenceResponse);
  82. // Updates the current user's explicit notification level for a room and returns
  83. // the resulting stored and effective levels.
  84. rpc UpdateRoomNotificationPreference(UpdateRoomNotificationPreferenceRequest) returns (UpdateNotificationPreferenceResponse);
  85. }