Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Url preview endpoint #3437

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

WIP: Url preview endpoint #3437

wants to merge 11 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 4.00943% with 407 lines in your changes missing coverage. Please review.

Project coverage is 67.15%. Comparing base (6cd1285) to head (ea0b25b).

Files with missing lines Patch % Lines
mediaapi/routing/url_preview.go 3.08% 374 Missing and 3 partials ⚠️
mediaapi/thumbnailer/thumbnailer_nfnt.go 0.00% 24 Missing ⚠️
setup/config/config_mediaapi.go 40.00% 2 Missing and 1 partial ⚠️
mediaapi/fileutils/fileutils.go 0.00% 2 Missing ⚠️
mediaapi/routing/download.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3437      +/-   ##
==========================================
- Coverage   67.74%   67.15%   -0.59%     
==========================================
  Files         518      519       +1     
  Lines       47457    47880     +423     
==========================================
+ Hits        32150    32156       +6     
- Misses      11311    11725     +414     
- Partials     3996     3999       +3     
Flag Coverage Δ
unittests 52.41% <4.00%> (-0.44%) ⬇️

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.

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

Successfully merging this pull request may close these issues.

1 participant