channel.messages: use fill_embed

- embed.sanitizer: fix fetching of keys in app.config
This commit is contained in:
Luna 2018-12-05 02:55:09 -03:00
parent e3653cac87
commit 75a7c4d83a
2 changed files with 9 additions and 6 deletions

View File

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

View File

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