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

Commit

Permalink
Move HTML parsing to a separate file for URL previews. (#11566)
Browse files Browse the repository at this point in the history
* Splits the logic for parsing HTML from the resource handling code.
* Fix a circular import in the oEmbed code (which uses the HTML parsing code).
* Renames some of the HTML parsing methods to:
  * Make it clear which methods are "internal" to the module.
  * Clarify what the methods do.
  • Loading branch information
clokep authored Dec 13, 2021
1 parent 5305a5e commit eb39da6
Show file tree
Hide file tree
Showing 6 changed files with 432 additions and 401 deletions.
1 change: 1 addition & 0 deletions changelog.d/11566.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Split the HTML parsing code from the URL preview resource code.
5 changes: 2 additions & 3 deletions synapse/rest/media/v1/oembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import attr

from synapse.rest.media.v1.preview_html import parse_html_description
from synapse.types import JsonDict
from synapse.util import json_decoder

Expand Down Expand Up @@ -245,8 +246,6 @@ def calc_description_and_urls(open_graph_response: JsonDict, html_body: str) ->
if video_urls:
open_graph_response["og:video"] = video_urls[0]

from synapse.rest.media.v1.preview_url_resource import _calc_description

description = _calc_description(tree)
description = parse_html_description(tree)
if description:
open_graph_response["og:description"] = description
Loading

0 comments on commit eb39da6

Please sign in to comment.