attachments.proto 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "chatto/api/v1/common.proto";
  5. import "chatto/api/v1/message_types.proto";
  6. import "google/protobuf/timestamp.proto";
  7. // Room-scoped binary asset metadata and freshly signed URLs.
  8. message Asset {
  9. // Stable asset ID.
  10. string id = 1;
  11. // Original filename.
  12. string filename = 2;
  13. // MIME content type.
  14. string content_type = 3;
  15. // Stored file size in bytes.
  16. int64 size = 4;
  17. // Media width when known.
  18. int32 width = 5;
  19. // Media height when known.
  20. int32 height = 6;
  21. // Signed URL for the original asset bytes.
  22. MessageAssetUrl asset_url = 7;
  23. // Signed URL for a transformed image thumbnail.
  24. MessageAssetUrl thumbnail_asset_url = 8;
  25. // Video processing state when this asset is a video attachment.
  26. MessageVideoProcessing video_processing = 9;
  27. }
  28. // One current room attachment and its message anchor.
  29. message RoomAttachmentListItem {
  30. // Attachment metadata and signed URLs.
  31. Asset attachment = 1;
  32. // Message event containing the attachment.
  33. string message_event_id = 2;
  34. // Thread root event ID when the containing message is a thread reply.
  35. string thread_root_event_id = 3;
  36. // Message creation timestamp.
  37. google.protobuf.Timestamp created_at = 4;
  38. }
  39. // Request to read one room-scoped asset with freshly signed URLs.
  40. message GetAssetRequest {
  41. // Required. Room that owns the asset.
  42. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  43. // Required. Asset ID.
  44. string asset_id = 2 [(buf.validate.field).string.min_len = 1];
  45. // Thumbnail URL options. Defaults are applied when absent.
  46. ImageTransformOptions thumbnail = 3;
  47. }
  48. // Response containing one room-scoped asset.
  49. message GetAssetResponse {
  50. // Asset metadata and signed URLs.
  51. Asset asset = 1;
  52. }
  53. // Request to read many room-scoped assets with freshly signed URLs.
  54. message BatchGetAssetsRequest {
  55. // Required. Room that owns the assets.
  56. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  57. // Required. Asset IDs. Missing, deleted, and wrong-room asset IDs are omitted.
  58. repeated string asset_ids = 2 [(buf.validate.field).repeated = {
  59. min_items: 1
  60. max_items: 100
  61. items: {
  62. string: {min_len: 1}
  63. }
  64. }];
  65. // Thumbnail URL options. Defaults are applied when absent.
  66. ImageTransformOptions thumbnail = 3;
  67. }
  68. // Response containing room-scoped assets.
  69. message BatchGetAssetsResponse {
  70. // Assets in first-seen request order.
  71. repeated Asset assets = 1;
  72. }
  73. // Reads room-scoped asset metadata and freshly signed asset URLs.
  74. service AssetService {
  75. // Reads one asset. Authentication and room membership are required. Returns
  76. // NOT_FOUND when the asset is missing, deleted, or owned by a different room.
  77. rpc GetAsset(GetAssetRequest) returns (GetAssetResponse);
  78. // Reads many assets in one room. Authentication and room membership are
  79. // required. Missing, deleted, and wrong-room asset IDs are omitted. Results
  80. // preserve first-seen request order and repeated asset IDs are de-duplicated.
  81. rpc BatchGetAssets(BatchGetAssetsRequest) returns (BatchGetAssetsResponse);
  82. }