embed.messages: always pass url as EmbedURL

- embed.sanitizer: handle non-EmbedURL on fetch_embed
This commit is contained in:
Luna 2019-03-19 00:44:34 -03:00
parent bc13e06eee
commit 4a56500adb
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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}'