schemas: change avatar_url in webhook exec to EmbedURL coerce

- embed.schemas: add EmbedURL.scheme
This commit is contained in:
Luna 2019-03-18 23:08:10 -03:00
parent 507393678e
commit 1d9c9f7b85
2 changed files with 7 additions and 7 deletions

View File

@ -31,16 +31,18 @@ class EmbedURL:
if parsed.scheme not in ('http', 'https', 'attachment'): if parsed.scheme not in ('http', 'https', 'attachment'):
raise ValueError('Invalid URL scheme') raise ValueError('Invalid URL scheme')
self.scheme = parsed.scheme
self.raw_url = url self.raw_url = url
self.parsed = parsed self.parsed = parsed
@property @property
def url(self): def url(self) -> str:
"""Return the URL.""" """Return the unparsed URL."""
return urllib.parse.urlunparse(self.parsed) return urllib.parse.urlunparse(self.parsed)
@property @property
def to_json(self): def to_json(self) -> str:
"""'json' version of the url."""
return self.url return self.url

View File

@ -31,7 +31,7 @@ from .enums import (
MessageNotifications, ChannelType, VerificationLevel MessageNotifications, ChannelType, VerificationLevel
) )
from litecord.embed.schemas import EMBED_OBJECT from litecord.embed.schemas import EMBED_OBJECT, EmbedURL
log = Logger(__name__) log = Logger(__name__)
@ -710,10 +710,8 @@ WEBHOOK_MESSAGE_CREATE = {
'minlength': 2, 'maxlength': 32, 'required': False 'minlength': 2, 'maxlength': 32, 'required': False
}, },
# TODO: url type, or something...
'avatar_url': { 'avatar_url': {
# 'type': 'url', 'required': False 'coerce': EmbedURL, 'required': False
'type': 'string', 'required': False
}, },
'embeds': { 'embeds': {