From 1d9c9f7b852e37a6a82b85fba2dcf69a8d9af795 Mon Sep 17 00:00:00 2001 From: Luna Date: Mon, 18 Mar 2019 23:08:10 -0300 Subject: [PATCH] schemas: change avatar_url in webhook exec to EmbedURL coerce - embed.schemas: add EmbedURL.scheme --- litecord/embed/schemas.py | 8 +++++--- litecord/schemas.py | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/litecord/embed/schemas.py b/litecord/embed/schemas.py index 61452c6..63d8246 100644 --- a/litecord/embed/schemas.py +++ b/litecord/embed/schemas.py @@ -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 diff --git a/litecord/schemas.py b/litecord/schemas.py index fd1553e..980a7ff 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -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': {