mirror of https://gitlab.com/litecord/litecord.git
embed.messages: always pass url as EmbedURL
- embed.sanitizer: handle non-EmbedURL on fetch_embed
This commit is contained in:
parent
bc13e06eee
commit
4a56500adb
|
|
@ -140,10 +140,12 @@ async def process_url_embed(config, storage, dispatcher,
|
||||||
new_embeds = []
|
new_embeds = []
|
||||||
|
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
url = EmbedURL(url)
|
||||||
|
|
||||||
if is_media_url(url):
|
if is_media_url(url):
|
||||||
embed = await insert_media_meta(url, config, session)
|
embed = await insert_media_meta(url, config, session)
|
||||||
else:
|
else:
|
||||||
embed = await insert_mp_embed(parsed, config, session)
|
embed = await insert_mp_embed(url, config, session)
|
||||||
|
|
||||||
if not embed:
|
if not embed:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -156,14 +156,14 @@ async def fetch_raw_img(url, *, config=None, session=None) -> Optional[tuple]:
|
||||||
return resp, await resp.read()
|
return resp, await resp.read()
|
||||||
|
|
||||||
|
|
||||||
async def fetch_embed(parsed, *, config=None, session=None) -> dict:
|
async def fetch_embed(url, *, config=None, session=None) -> dict:
|
||||||
"""Fetch an embed"""
|
"""Fetch an embed"""
|
||||||
|
config, session = _mk_cfg_sess(config, session)
|
||||||
|
|
||||||
if session is None:
|
if not isinstance(url, EmbedURL):
|
||||||
session = app.session
|
url = EmbedURL(url)
|
||||||
|
|
||||||
if config is None:
|
parsed = url.parsed
|
||||||
config = app.config
|
|
||||||
|
|
||||||
# TODO: handle query string
|
# TODO: handle query string
|
||||||
md_path = f'{parsed.scheme}/{parsed.netloc}{parsed.path}'
|
md_path = f'{parsed.scheme}/{parsed.netloc}{parsed.path}'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue