push_notifications.proto 1.9 KB

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