presence.proto 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. // Saved choice visible only to the authenticated account itself.
  5. message PresencePreference {
  6. // Saved choice, independent of liveness. OFFLINE means "Appear Offline";
  7. // DO_NOT_DISTURB suppresses alerts even while disconnected.
  8. PresenceStatus status = 1;
  9. // Opaque revision required when replacing this choice.
  10. string revision = 2;
  11. }
  12. // Read the authenticated account's own choice; accepts no other user ID.
  13. message GetPresencePreferenceRequest {}
  14. // Current private choice, or absence before first initialization.
  15. message GetPresencePreferenceResponse {
  16. // Absent until the account first saves a choice.
  17. PresencePreference preference = 1;
  18. }
  19. // An explicit selection. Heartbeats must not call this operation.
  20. message SetPresencePreferenceRequest {
  21. // Explicit new choice for every device on this server.
  22. PresenceStatus status = 1 [(buf.validate.field).enum = {defined_only: true, not_in: [0]}];
  23. // Revision from the last read; empty only when initializing an absent choice.
  24. string expected_revision = 2;
  25. }
  26. // Acknowledged current choice after the selection commits.
  27. message SetPresencePreferenceResponse {
  28. PresencePreference preference = 1;
  29. }
  30. // Refresh the authenticated account's liveness without supplying a choice.
  31. message RefreshPresenceRequest {}
  32. // Current private choice after refreshing liveness.
  33. message RefreshPresenceResponse {
  34. // Private saved choice; clients use this to recover missed device updates.
  35. PresencePreference preference = 1;
  36. }
  37. // Availability used for private choices and effective public presence.
  38. //
  39. // Public Offline reveals neither connection liveness nor whether the account
  40. // selected "Appear Offline". A saved Online, Away, or Do Not Disturb choice
  41. // becomes public Offline when no device refreshes liveness.
  42. enum PresenceStatus {
  43. // No presence status was specified.
  44. PRESENCE_STATUS_UNSPECIFIED = 0;
  45. // Online while at least one device refreshes liveness.
  46. PRESENCE_STATUS_ONLINE = 1;
  47. // Away while at least one device refreshes liveness.
  48. PRESENCE_STATUS_AWAY = 2;
  49. // Do Not Disturb. A saved choice suppresses alerts even while disconnected.
  50. PRESENCE_STATUS_DO_NOT_DISTURB = 3;
  51. // No public live presence. As a saved choice, suppresses presence and typing.
  52. PRESENCE_STATUS_OFFLINE = 4;
  53. }
  54. // Legacy live report. A saved private choice takes precedence over this report.
  55. message SetPresenceRequest {
  56. // Live status to store for the authenticated user. Offline is rejected.
  57. PresenceStatus status = 1 [(buf.validate.field).enum = {
  58. defined_only: true
  59. not_in: [0, 4]
  60. }];
  61. // Legacy manual-selection flag. It cannot replace a saved private choice.
  62. // New clients use SetPresencePreference for explicit selections.
  63. bool user_selected = 2;
  64. }
  65. // Result of updating live presence.
  66. message SetPresenceResponse {
  67. // Reportable status accepted and stored by the server.
  68. PresenceStatus status = 1;
  69. }