attachments.proto 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. // User-provided description for this attachment. Absent when the attachment
  39. // has no description.
  40. optional string description = 5;
  41. }
  42. // Request to read one room-scoped asset with freshly signed URLs.
  43. message GetAssetRequest {
  44. // Required. Room that owns the asset.
  45. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  46. // Required. Asset ID.
  47. string asset_id = 2 [(buf.validate.field).string.min_len = 1];
  48. // Thumbnail URL options. Defaults are applied when absent.
  49. ImageTransformOptions thumbnail = 3;
  50. }
  51. // Response containing one room-scoped asset.
  52. message GetAssetResponse {
  53. // Asset metadata and signed URLs.
  54. Asset asset = 1;
  55. }
  56. // Request to read many room-scoped assets with freshly signed URLs.
  57. message BatchGetAssetsRequest {
  58. // Required. Room that owns the assets.
  59. string room_id = 1 [(buf.validate.field).string.min_len = 1];
  60. // Required. Asset IDs. Missing, deleted, and wrong-room asset IDs are omitted.
  61. repeated string asset_ids = 2 [(buf.validate.field).repeated = {
  62. min_items: 1
  63. max_items: 100
  64. items: {
  65. string: {min_len: 1}
  66. }
  67. }];
  68. // Thumbnail URL options. Defaults are applied when absent.
  69. ImageTransformOptions thumbnail = 3;
  70. }
  71. // Response containing room-scoped assets.
  72. message BatchGetAssetsResponse {
  73. // Assets in first-seen request order.
  74. repeated Asset assets = 1;
  75. }
  76. // Reads room-scoped asset metadata and freshly signed asset URLs.
  77. service AssetService {
  78. // Reads one asset. Authentication and room membership are required.
  79. // Assets also require message.read or a matching thread relationship with
  80. // message.read-interactions. Returns NOT_FOUND when the asset is missing,
  81. // deleted, or owned by a
  82. // different room.
  83. rpc GetAsset(GetAssetRequest) returns (GetAssetResponse);
  84. // Reads many assets in one room. Authentication and room membership are
  85. // required. Assets also require message.read or a matching thread
  86. // relationship with message.read-interactions. Missing, deleted, wrong-room, and inaccessible asset
  87. // IDs are omitted. Results preserve first-seen request order, and repeated
  88. // asset IDs are de-duplicated.
  89. rpc BatchGetAssets(BatchGetAssetsRequest) returns (BatchGetAssetsResponse);
  90. }