embed.sanitizer: add log warn

- channel.messages: handle meta being None
 - schemas: add gift_code_sku_id
This commit is contained in:
Luna 2019-02-01 20:57:12 -03:00
parent 9f56c7a26e
commit 9b76c472d0
3 changed files with 9 additions and 1 deletions

View File

@ -272,6 +272,9 @@ async def process_url_embed(config, storage, dispatcher, session, payload: dict)
img_proxy_url = proxify(url, config=config) img_proxy_url = proxify(url, config=config)
meta = await fetch_metadata(url, config=config, session=session) meta = await fetch_metadata(url, config=config, session=session)
if meta is None:
continue
if not meta['image']: if not meta['image']:
continue continue

View File

@ -119,6 +119,10 @@ async def fetch_metadata(url, *, config=None, session=None) -> dict:
async with session.get(request_url) as resp: async with session.get(request_url) as resp:
if resp.status != 200: if resp.status != 200:
body = await resp.text()
log.warning('failed to generate meta for {!r}: {} {!r}',
url, resp.status, body)
return return
return await resp.json() return await resp.json()

View File

@ -179,7 +179,8 @@ REGISTER = {
'invite': {'type': 'string', 'required': False, 'nullable': True}, # optional 'invite': {'type': 'string', 'required': False, 'nullable': True}, # optional
'fingerprint': {'type': 'string', 'required': False, 'nullable': True}, # these are sent by official client 'fingerprint': {'type': 'string', 'required': False, 'nullable': True}, # these are sent by official client
'captcha_key': {'type': 'string', 'required': False, 'nullable': True}, 'captcha_key': {'type': 'string', 'required': False, 'nullable': True},
'consent': {'type': 'boolean'} 'consent': {'type': 'boolean'},
'gift_code_sku_id': {'type': 'string', 'required': False, 'nullable': True}
} }
# only used by us, not discord, hence 'invcode' (to separate from discord) # only used by us, not discord, hence 'invcode' (to separate from discord)