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'):
raise ValueError('Invalid URL scheme')
self.scheme = parsed.scheme
self.raw_url = url
self.parsed = parsed
@property
def url(self):
"""Return the URL."""
def url(self) -> str:
"""Return the unparsed URL."""
return urllib.parse.urlunparse(self.parsed)
@property
def to_json(self):
def to_json(self) -> str:
"""'json' version of the url."""
return self.url

View File

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