From 5aacd13176fdeabc1388c60e02aef16939acce3c Mon Sep 17 00:00:00 2001 From: clokep Date: Tue, 12 Jul 2022 19:02:38 +0000 Subject: deploy: 1381563988c6dc7a2b8801b736b1f0c663970da8 --- develop/development/cas.html | 2 +- develop/development/contributing_guide.html | 2 +- develop/development/database_schema.html | 2 +- develop/development/demo.html | 2 +- develop/development/dependencies.html | 2 +- develop/development/experimental_features.html | 2 +- develop/development/git.html | 2 +- .../development/internal_documentation/index.html | 2 +- develop/development/releases.html | 2 +- develop/development/reviews.html | 2 +- develop/development/room-dag-concepts.html | 2 +- develop/development/saml.html | 2 +- .../synapse_architecture/cancellation.html | 2 +- develop/development/url_previews.html | 274 --------------------- 14 files changed, 13 insertions(+), 287 deletions(-) delete mode 100644 develop/development/url_previews.html (limited to 'develop/development') diff --git a/develop/development/cas.html b/develop/development/cas.html index e6c4b762ca..96b5dad8ed 100644 --- a/develop/development/cas.html +++ b/develop/development/cas.html @@ -76,7 +76,7 @@ diff --git a/develop/development/contributing_guide.html b/develop/development/contributing_guide.html index 2778bd52c4..bffc1a46e1 100644 --- a/develop/development/contributing_guide.html +++ b/develop/development/contributing_guide.html @@ -76,7 +76,7 @@ diff --git a/develop/development/database_schema.html b/develop/development/database_schema.html index bf2230d983..743cb6c2c5 100644 --- a/develop/development/database_schema.html +++ b/develop/development/database_schema.html @@ -76,7 +76,7 @@ diff --git a/develop/development/demo.html b/develop/development/demo.html index eac5b202ab..66f5dffb04 100644 --- a/develop/development/demo.html +++ b/develop/development/demo.html @@ -76,7 +76,7 @@ diff --git a/develop/development/dependencies.html b/develop/development/dependencies.html index 4896de3a78..19cf215053 100644 --- a/develop/development/dependencies.html +++ b/develop/development/dependencies.html @@ -76,7 +76,7 @@ diff --git a/develop/development/experimental_features.html b/develop/development/experimental_features.html index 66d1414c33..c8bd7590e4 100644 --- a/develop/development/experimental_features.html +++ b/develop/development/experimental_features.html @@ -76,7 +76,7 @@ diff --git a/develop/development/git.html b/develop/development/git.html index 606a9ddb52..efbd1695df 100644 --- a/develop/development/git.html +++ b/develop/development/git.html @@ -76,7 +76,7 @@ diff --git a/develop/development/internal_documentation/index.html b/develop/development/internal_documentation/index.html index 6d515fc55c..41bb1d5fda 100644 --- a/develop/development/internal_documentation/index.html +++ b/develop/development/internal_documentation/index.html @@ -76,7 +76,7 @@ diff --git a/develop/development/releases.html b/develop/development/releases.html index 83277dc1d9..7c02df8568 100644 --- a/develop/development/releases.html +++ b/develop/development/releases.html @@ -76,7 +76,7 @@ diff --git a/develop/development/reviews.html b/develop/development/reviews.html index 03a01acc62..22a5454d17 100644 --- a/develop/development/reviews.html +++ b/develop/development/reviews.html @@ -76,7 +76,7 @@ diff --git a/develop/development/room-dag-concepts.html b/develop/development/room-dag-concepts.html index bc310dd67f..61e5e2a0b7 100644 --- a/develop/development/room-dag-concepts.html +++ b/develop/development/room-dag-concepts.html @@ -76,7 +76,7 @@ diff --git a/develop/development/saml.html b/develop/development/saml.html index dddc8772cb..ecefc6ed8f 100644 --- a/develop/development/saml.html +++ b/develop/development/saml.html @@ -76,7 +76,7 @@ diff --git a/develop/development/synapse_architecture/cancellation.html b/develop/development/synapse_architecture/cancellation.html index 899b39e0ec..e8a8f9b13c 100644 --- a/develop/development/synapse_architecture/cancellation.html +++ b/develop/development/synapse_architecture/cancellation.html @@ -76,7 +76,7 @@ diff --git a/develop/development/url_previews.html b/develop/development/url_previews.html deleted file mode 100644 index b09a47f793..0000000000 --- a/develop/development/url_previews.html +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - URL Previews - Synapse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - -
-
- -
- -
- -

URL Previews

-

For information on how to enable URL previews in synapse, please see the config manual.

-

The GET /_matrix/media/r0/preview_url endpoint provides a generic preview API -for URLs which outputs Open Graph responses (with some Matrix -specific additions).

-

This does have trade-offs compared to other designs:

-
    -
  • Pros: -
      -
    • Simple and flexible; can be used by any clients at any point
    • -
    -
  • -
  • Cons: -
      -
    • If each homeserver provides one of these independently, all the HSes in a -room may needlessly DoS the target URI
    • -
    • The URL metadata must be stored somewhere, rather than just using Matrix -itself to store the media.
    • -
    • Matrix cannot be used to distribute the metadata between homeservers.
    • -
    -
  • -
-

When Synapse is asked to preview a URL it does the following:

-
    -
  1. Checks against a URL blacklist (defined as url_preview_url_blacklist in the -config).
  2. -
  3. Checks the in-memory cache by URLs and returns the result if it exists. (This -is also used to de-duplicate processing of multiple in-flight requests at once.)
  4. -
  5. Kicks off a background process to generate a preview: -
      -
    1. Checks the database cache by URL and timestamp and returns the result if it -has not expired and was successful (a 2xx return code).
    2. -
    3. Checks if the URL matches an oEmbed pattern. If it -does, update the URL to download.
    4. -
    5. Downloads the URL and stores it into a file via the media storage provider -and saves the local media metadata.
    6. -
    7. If the media is an image: -
        -
      1. Generates thumbnails.
      2. -
      3. Generates an Open Graph response based on image properties.
      4. -
      -
    8. -
    9. If the media is HTML: -
        -
      1. Decodes the HTML via the stored file.
      2. -
      3. Generates an Open Graph response from the HTML.
      4. -
      5. If a JSON oEmbed URL was found in the HTML via autodiscovery: -
          -
        1. Downloads the URL and stores it into a file via the media storage provider -and saves the local media metadata.
        2. -
        3. Convert the oEmbed response to an Open Graph response.
        4. -
        5. Override any Open Graph data from the HTML with data from oEmbed.
        6. -
        -
      6. -
      7. If an image exists in the Open Graph response: -
          -
        1. Downloads the URL and stores it into a file via the media storage -provider and saves the local media metadata.
        2. -
        3. Generates thumbnails.
        4. -
        5. Updates the Open Graph response based on image properties.
        6. -
        -
      8. -
      -
    10. -
    11. If the media is JSON and an oEmbed URL was found: -
        -
      1. Convert the oEmbed response to an Open Graph response.
      2. -
      3. If a thumbnail or image is in the oEmbed response: -
          -
        1. Downloads the URL and stores it into a file via the media storage -provider and saves the local media metadata.
        2. -
        3. Generates thumbnails.
        4. -
        5. Updates the Open Graph response based on image properties.
        6. -
        -
      4. -
      -
    12. -
    13. Stores the result in the database cache.
    14. -
    -
  6. -
  7. Returns the result.
  8. -
-

The in-memory cache expires after 1 hour.

-

Expired entries in the database cache (and their associated media files) are -deleted every 10 seconds. The default expiration time is 1 hour from download.

- -
- - -
-
- - - -
- - - - - - - - - - - - - \ No newline at end of file -- cgit 1.5.1