push_notifications.proto 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "google/protobuf/descriptor.proto";
  5. // Browser Web Push subscription commands for the current user.
  6. service PushNotificationService {
  7. // Stores or updates the caller's browser push subscription.
  8. //
  9. // The server must have Web Push configured. Clients normally call this after
  10. // the browser grants notification permission and returns a PushSubscription.
  11. rpc Subscribe(SubscribePushRequest) returns (SubscribePushResponse);
  12. // Removes the caller's browser push subscription by endpoint.
  13. //
  14. // The call is idempotent: removing an unknown endpoint still succeeds.
  15. rpc Unsubscribe(UnsubscribePushRequest) returns (UnsubscribePushResponse) {
  16. option idempotency_level = IDEMPOTENT;
  17. }
  18. }
  19. // Request to store a PushSubscription returned by the browser Push API.
  20. message SubscribePushRequest {
  21. // Push service endpoint URL.
  22. string endpoint = 1 [(buf.validate.field).string = {
  23. min_len: 1
  24. max_len: 4096
  25. }];
  26. // Client P-256 ECDH public key from PushSubscription.keys.p256dh.
  27. string p256dh = 2 [(buf.validate.field).string = {
  28. min_len: 1
  29. max_len: 256
  30. }];
  31. // Authentication secret from PushSubscription.keys.auth.
  32. string auth = 3 [(buf.validate.field).string = {
  33. min_len: 1
  34. max_len: 128
  35. }];
  36. // Optional browser user-agent string for device identification.
  37. optional string user_agent = 4 [(buf.validate.field).string.max_len = 512];
  38. }
  39. // Response from storing a browser push subscription.
  40. message SubscribePushResponse {
  41. // True when the subscription was stored.
  42. bool subscribed = 1;
  43. }
  44. // Request to remove a browser push subscription.
  45. message UnsubscribePushRequest {
  46. // Push service endpoint URL to remove.
  47. string endpoint = 1 [(buf.validate.field).string = {
  48. min_len: 1
  49. max_len: 4096
  50. }];
  51. }
  52. // Response from removing a browser push subscription.
  53. message UnsubscribePushResponse {
  54. // True when the request completed.
  55. bool unsubscribed = 1;
  56. }