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

Url preview endpoint #3437

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

Url preview endpoint #3437

wants to merge 15 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 <[email protected]>

Signed-off-by: Aleksandr Dubovikov <[email protected]>
Signed-off-by: Aleksandr Dubovikov <[email protected]>
Signed-off-by: Aleksandr Dubovikov <[email protected]>
@adnull adnull requested a review from a team as a code owner September 30, 2024 11:28
Signed-off-by: Aleksandr Dubovikov <[email protected]>
@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.

Signed-off-by: Aleksandr Dubovikov <[email protected]>
Signed-off-by: Aleksandr Dubovikov <[email protected]>
Signed-off-by: Aleksandr Dubovikov <[email protected]>
Signed-off-by: Aleksandr Dubovikov <[email protected]>
@adnull adnull changed the title WIP: Url preview endpoint Url preview endpoint Oct 17, 2024
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