link_previews.proto 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. // Request to fetch server-side link preview metadata for a URL.
  5. message FetchLinkPreviewRequest {
  6. // URL to preview.
  7. string url = 1 [
  8. (buf.validate.field).string.min_len = 1,
  9. (buf.validate.field).string.max_len = 2048
  10. ];
  11. }
  12. // Link preview metadata used by message composers and room timeline events.
  13. //
  14. // Clients should treat optional metadata as unavailable when absent. Message
  15. // creation accepts only the preview_token returned by FetchLinkPreview, not
  16. // client-provided metadata fields.
  17. message LinkPreview {
  18. // Previewed URL.
  19. string url = 1;
  20. // Page or embed title.
  21. optional string title = 2;
  22. // Page or embed description.
  23. optional string description = 3;
  24. // Preview image URL, when available.
  25. optional string image_url = 4;
  26. // Existing server asset ID for the preview image, when cached or stored with
  27. // the message.
  28. optional string image_asset_id = 5;
  29. // Site name, when known.
  30. optional string site_name = 6;
  31. // Embed provider or type, when recognized.
  32. optional string embed_type = 7;
  33. // Provider-specific embed ID, when recognized.
  34. optional string embed_id = 8;
  35. }
  36. // Result of fetching link preview metadata.
  37. message FetchLinkPreviewResponse {
  38. // Preview metadata, or absent when the URL cannot be previewed.
  39. LinkPreview preview = 1;
  40. // Short-lived opaque token to pass to CreateMessage.link_preview_token when
  41. // the user posts this preview.
  42. string preview_token = 2;
  43. }