Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Url preview endpoint #3437

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Url preview endpoint #3437

wants to merge 29 commits into from

Conversation

adnull
Copy link
Contributor

@adnull adnull commented Sep 30, 2024

This PR introduces the missing URL Preview functionality ( Issue #1303 )

According to the specification that endpoint requests require authentication and are rate limited. There are both endpoints (v1 and v3) as some clients still use deprecated endpoints for url preview requests.

Key features:

  • takes info from html pages or image links. Max image size downloadable is configurable. Timeout is configurable
  • stores the url's image as a thumbnail in media storage if the thumbnail size for url previews is configured. Otherwise stores the original image (to make it sy-test compatible).
  • uses the maxThumbnailGenerators variable to prevent overload. Waits 30s for free generator.
  • keeps an in-memory cache of url preview responses. The cache entry expiration time is configurable
  • stores the the url preview json responses in the media storage to prevent any extra load
  • url preview blacklist is configurable as a list of regexps in the config

Missing:

  • tests
  • synapse's ability to query/extract oEmbed resources

I'd like somebody to take a look at the code.

Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>

Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
@adnull adnull requested a review from a team as a code owner September 30, 2024 11:28
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
@adnull adnull changed the title Url preview endpoint WIP: Url preview endpoint Sep 30, 2024
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 68.23529% with 135 lines in your changes missing coverage. Please review.

Project coverage is 67.74%. Comparing base (6cd1285) to head (f58da42).

Files with missing lines Patch % Lines
mediaapi/routing/url_preview.go 68.46% 74 Missing and 49 partials ⚠️
mediaapi/thumbnailer/thumbnailer_nfnt.go 54.16% 7 Missing and 4 partials ⚠️
mediaapi/routing/download.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3437      +/-   ##
==========================================
- Coverage   67.74%   67.74%   -0.01%     
==========================================
  Files         518      519       +1     
  Lines       47457    47881     +424     
==========================================
+ Hits        32150    32437     +287     
- Misses      11311    11393      +82     
- Partials     3996     4051      +55     
Flag Coverage Δ
unittests 53.06% <68.23%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

adnull and others added 11 commits October 8, 2024 17:22
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
github.com/matrix-org/dendrite to github.com/element-hq/dendrite
@adnull adnull changed the title WIP: Url preview endpoint Url preview endpoint Oct 17, 2024
@S7evinK
Copy link
Contributor

S7evinK commented Nov 14, 2024

Thanks for contributing to Dendrite!

The repo has been cloned into element-hq/dendrite and made the switch to AGPL as per https://matrix.org/blog/2023/11/06/future-of-synapse-dendrite/.
For more information, feel free to read this and this

If you still wish to contribute under the new license, feel free to create a new PR over at element-hq/dendrite.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants