Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Conversation

clokep
Copy link
Member

@clokep clokep commented Sep 13, 2021

This reworks how we do oEmbed quite a bit, with an eye towards being able to support auto-discovery and other features. It attempts to fit the oEmbed previews a bit better into the preview framework by moving it to a higher level. This allows for us re-using more of the framework we use for generating previews.

  • There's a few commits that refactor things to split out methods / move some code around.
  • Move oEmbed higher up in the process chain -- use the standard _download_file method and then post-process the result (like we do for HTML).

This also updates the tests to be a bit more reasonable.

Related to #2752.

@clokep clokep requested review from a team and removed request for a team September 14, 2021 12:10
@clokep clokep force-pushed the clokep/oembed-improvements branch from 057d6b4 to b00f68a Compare September 14, 2021 16:31
@clokep clokep changed the title Revamp oEmbed previews Refactor oEmbed previews Sep 14, 2021
@clokep clokep mentioned this pull request Sep 14, 2021
@clokep
Copy link
Member Author

clokep commented Sep 14, 2021

I think this is ready for review. There's currently two other PRs built on this that might be useful to look at where this is heading (and why we want to refactor this code).

@clokep clokep requested a review from a team September 14, 2021 18:34
Copy link
Contributor

@reivilibre reivilibre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I know enough to review this properly, but a couple of comments

@reivilibre reivilibre requested a review from a team September 16, 2021 13:25
@clokep clokep removed the request for review from a team September 16, 2021 15:01
@clokep clokep requested a review from a team September 16, 2021 16:06
@richvdh richvdh self-assigned this Sep 21, 2021
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks generally great! a few comments.


# Use the cache age from the oEmbed result, instead of the HTTP response.
if oembed_response.cache_age is not None:
expiration_ts_ms = oembed_response.cache_age + media_info.created_ts_ms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we cap this, to avoid things being cached for ever?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we definitely should. Do you have any thoughts for a max-age? 24 hours? A week?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with 24 hours, but should be easy enough to change. I also chose to apply this to all previews, not just ones from oEmbed. Although other previews currently always use 1 hour:

# FIXME: we should calculate a proper expiration based on the
# Cache-Control and Expire headers. But for now, assume 1 hour.
expires = ONE_HOUR

@clokep clokep requested a review from richvdh September 21, 2021 14:25
@clokep
Copy link
Member Author

clokep commented Sep 21, 2021

A couple of outstanding questions so I put it back on your review queue @richvdh!

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@clokep clokep enabled auto-merge (squash) September 21, 2021 15:50
@clokep clokep merged commit ba7a91a into develop Sep 21, 2021
@clokep clokep deleted the clokep/oembed-improvements branch September 21, 2021 16:09
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