mirror of https://gitlab.com/litecord/litecord.git
images: add bytelimit
- guild.emoji: add 128x128 limit and 128kb limit - types: add KILOBYTES
This commit is contained in:
parent
d3bc826504
commit
d9a1923e54
|
|
@ -4,6 +4,7 @@ from litecord.auth import token_check
|
|||
from litecord.blueprints.checks import guild_check, guild_perm_check
|
||||
from litecord.schemas import validate, NEW_EMOJI, PATCH_EMOJI
|
||||
from litecord.snowflake import get_snowflake
|
||||
from litecord.types import KILOBYTES
|
||||
|
||||
bp = Blueprint('guild.emoji', __name__)
|
||||
|
||||
|
|
@ -45,7 +46,12 @@ async def _put_emoji(guild_id):
|
|||
|
||||
emoji_id = get_snowflake()
|
||||
|
||||
icon = await app.icons.put('emoji', emoji_id, j['image'])
|
||||
icon = await app.icons.put(
|
||||
'emoji', emoji_id, j['image'],
|
||||
|
||||
# limits to emojis
|
||||
bsize=128 * KILOBYTES, size=(128, 128)
|
||||
)
|
||||
|
||||
await app.db.execute(
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -213,6 +213,10 @@ class IconManager:
|
|||
# get an extension for the given data uri
|
||||
extension = _get_ext(mime)
|
||||
|
||||
if 'bsize' in kwargs:
|
||||
if len(raw_data) > kwargs['bsize']:
|
||||
return Icon(None, None, '')
|
||||
|
||||
if 'size' in kwargs:
|
||||
image = Image.open(data_fd)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
KILOBYTES = 1024
|
||||
|
||||
|
||||
class Color:
|
||||
"""Custom color class"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue