diff --git a/litecord/blueprints/channel/messages.py b/litecord/blueprints/channel/messages.py index b1ef399..9f4d3ea 100644 --- a/litecord/blueprints/channel/messages.py +++ b/litecord/blueprints/channel/messages.py @@ -12,7 +12,7 @@ from litecord.snowflake import get_snowflake from litecord.schemas import validate, MESSAGE_CREATE from litecord.utils import pg_set_json -from litecord.embed import sanitize_embed +from litecord.embed.sanitizer import fill_embed log = Logger(__name__) @@ -260,7 +260,10 @@ async def _create_message(channel_id): 'tts': is_tts, 'nonce': int(j.get('nonce', 0)), 'everyone_mention': mentions_everyone or mentions_here, - 'embeds': [sanitize_embed(j['embed'])] if 'embed' in j else [], + + # fill_embed takes care of filling proxy and width/height + 'embeds': ([await fill_embed(j['embed'])] + if 'embed' in j else []), }) payload = await app.storage.get_message(message_id, user_id) diff --git a/litecord/embed/sanitizer.py b/litecord/embed/sanitizer.py index 1121cce..ec89cb9 100644 --- a/litecord/embed/sanitizer.py +++ b/litecord/embed/sanitizer.py @@ -58,9 +58,9 @@ def path_exists(embed: Embed, components: str): def proxify(url) -> str: """Return a mediaproxy url for the given EmbedURL.""" - md_base_url = app.config.MEDIA_PROXY + md_base_url = app.config['MEDIA_PROXY'] parsed = url.parsed - proto = 'https' if app.config.IS_SSL else 'http' + proto = 'https' if app.config['IS_SSL'] else 'http' return ( # base mediaproxy url @@ -74,9 +74,9 @@ async def fetch_metadata(url) -> dict: parsed = url.parsed md_path = f'{parsed.scheme}/{parsed.netloc}/{parsed.path}' - md_base_url = app.config.MEDIA_PROXY - proto = 'https' if app.config.IS_SSL else 'http' + md_base_url = app.config['MEDIA_PROXY'] + proto = 'https' if app.config['IS_SSL'] else 'http' request_url = f'{proto}://{md_base_url}/meta/{md_path}'