push_notifications.proto 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. // Sends a test notification to the caller's registered browser subscriptions.
  19. rpc SendTestNotification(SendTestPushNotificationRequest) returns (SendTestPushNotificationResponse);
  20. }
  21. // Request to store a PushSubscription returned by the browser Push API.
  22. message SubscribePushRequest {
  23. // Push service endpoint URL.
  24. string endpoint = 1 [(buf.validate.field).string = {
  25. min_len: 1
  26. max_len: 4096
  27. }];
  28. // Client P-256 ECDH public key from PushSubscription.keys.p256dh.
  29. string p256dh = 2 [(buf.validate.field).string = {
  30. min_len: 1
  31. max_len: 256
  32. }];
  33. // Authentication secret from PushSubscription.keys.auth.
  34. string auth = 3 [(buf.validate.field).string = {
  35. min_len: 1
  36. max_len: 128
  37. }];
  38. // Optional browser user-agent string for device identification.
  39. optional string user_agent = 4 [(buf.validate.field).string.max_len = 512];
  40. }
  41. // Response from storing a browser push subscription.
  42. message SubscribePushResponse {
  43. // True when the subscription was stored.
  44. bool subscribed = 1;
  45. }
  46. // Request to remove a browser push subscription.
  47. message UnsubscribePushRequest {
  48. // Push service endpoint URL to remove.
  49. string endpoint = 1 [(buf.validate.field).string = {
  50. min_len: 1
  51. max_len: 4096
  52. }];
  53. }
  54. // Response from removing a browser push subscription.
  55. message UnsubscribePushResponse {
  56. // True when the request completed.
  57. bool unsubscribed = 1;
  58. }
  59. // Request to test the current user's registered browser push subscriptions.
  60. message SendTestPushNotificationRequest {}
  61. // Result of sending a test Web Push notification.
  62. message SendTestPushNotificationResponse {
  63. // True when the push provider accepted the notification.
  64. bool sent = 1;
  65. }