mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-01 05:46:03 -04:00
Move HTML parsing to a separate file for URL previews. (#11566)
* 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.
This commit is contained in:
parent
5305a5e881
commit
eb39da6782
6 changed files with 432 additions and 401 deletions
|
@ -17,6 +17,7 @@ from typing import TYPE_CHECKING, List, Optional
|
|||
|
||||
import attr
|
||||
|
||||
from synapse.rest.media.v1.preview_html import parse_html_description
|
||||
from synapse.types import JsonDict
|
||||
from synapse.util import json_decoder
|
||||
|
||||
|
@ -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…
Add table
Add a link
Reference in a new issue