link_previews.proto 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "google/protobuf/timestamp.proto";
  5. // Request to fetch server-side link preview metadata for a URL.
  6. message FetchLinkPreviewRequest {
  7. // URL to preview.
  8. string url = 1 [
  9. (buf.validate.field).string.min_len = 1,
  10. (buf.validate.field).string.max_len = 2048
  11. ];
  12. }
  13. // Link preview metadata used by message composers and room timeline events.
  14. //
  15. // Clients should treat optional metadata as unavailable when absent. Message
  16. // creation accepts only the preview_token returned by FetchLinkPreview, not
  17. // client-provided metadata fields.
  18. message LinkPreview {
  19. // Previewed URL.
  20. string url = 1;
  21. // Page or embed title.
  22. optional string title = 2;
  23. // Page or embed description.
  24. optional string description = 3;
  25. // Preview image URL, when available.
  26. optional string image_url = 4;
  27. // Existing server asset ID for the preview image, when cached or stored with
  28. // the message.
  29. optional string image_asset_id = 5;
  30. // Site name, when known.
  31. optional string site_name = 6;
  32. // Embed provider or type, when recognized.
  33. optional string embed_type = 7;
  34. // Provider-specific embed ID, when recognized.
  35. optional string embed_id = 8;
  36. // Structured, provider-neutral social-post data for native rendering.
  37. SocialPostPreview social_post = 9;
  38. }
  39. // Bounded, provider-neutral social-post data used for native preview cards.
  40. message SocialPostPreview {
  41. // Stable lowercase provider identifier, such as "bluesky".
  42. string provider = 1;
  43. // Author shown on the post.
  44. SocialPostAuthor author = 2;
  45. // Plain-text post body.
  46. string text = 3;
  47. // Post publication time.
  48. google.protobuf.Timestamp published_at = 4;
  49. // Images attached directly to the post, in display order.
  50. repeated SocialPostImage images = 5;
  51. // Website card embedded in the post, when present.
  52. SocialPostExternalLink external_link = 6;
  53. // Provider-supplied content warning, when present.
  54. optional string content_warning = 7;
  55. // Canonical URL for this post. Always set for quoted posts; the outer post
  56. // may also use LinkPreview.url.
  57. string url = 8;
  58. // Post quoted by this post, when present. Quotes inside this snapshot are
  59. // omitted so preview size and rendering depth remain bounded.
  60. SocialPostPreview quoted_post = 9;
  61. }
  62. // Author shown on a social-post preview.
  63. message SocialPostAuthor {
  64. // Author display name.
  65. string display_name = 1;
  66. // Provider-native handle without a leading at-sign when applicable.
  67. string handle = 2;
  68. // Locally served author avatar URL, when available.
  69. optional string avatar_url = 3;
  70. // Locally stored author avatar asset ID, when available.
  71. optional string avatar_asset_id = 4;
  72. }
  73. // One image attached directly to a social post.
  74. message SocialPostImage {
  75. // Locally served image URL.
  76. string url = 1;
  77. // Locally stored image asset ID.
  78. string asset_id = 2;
  79. // Author-provided alternative text.
  80. optional string alt = 3;
  81. // Source aspect-ratio width, when known.
  82. optional uint32 width = 4;
  83. // Source aspect-ratio height, when known.
  84. optional uint32 height = 5;
  85. }
  86. // Website card embedded in a social post.
  87. message SocialPostExternalLink {
  88. // Destination URL.
  89. string url = 1;
  90. // Card title, when available.
  91. optional string title = 2;
  92. // Card description, when available.
  93. optional string description = 3;
  94. // Locally served card image URL, when available.
  95. optional string image_url = 4;
  96. // Locally stored card image asset ID, when available.
  97. optional string image_asset_id = 5;
  98. }
  99. // Result of fetching link preview metadata.
  100. message FetchLinkPreviewResponse {
  101. // Preview metadata, or absent when the URL cannot be previewed.
  102. LinkPreview preview = 1;
  103. // Short-lived opaque token to pass to CreateMessage.link_preview_token when
  104. // the user posts this preview.
  105. string preview_token = 2;
  106. }