From 47913f5c4911b4e64aedca20497571bb662a0c26 Mon Sep 17 00:00:00 2001 From: Khakers <22665282+khakers@users.noreply.github.com> Date: Wed, 2 Aug 2023 17:14:52 -0700 Subject: [PATCH] Improve is_image detection to actually detect images (excluding videos) and add content_type value --- CHANGELOG.md | 6 +++++- core/clients.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f672f721a..1c6f551307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,17 @@ however, insignificant breaking changes do not guarantee a major version bump, s # [UNRELEASED] ### Breaking -- Completely rewritten blocklist system. Blocklisting now runs off it's own mongoDB collection. This once again introduces backwards incompatible schema changes, so a manual migration is required. You may upgrade from both v4.0 and v4.1 using the `[p]migrate blocklist` command. This removes any need to perform the previous migration steps in v4.1.0, you may upgrade directly to this version. After running the command, blocklist functionality will return and legacy config based blocks will have been deleted. You should always backup your config before migration. +- Completely rewritten blocklist system. Blocklisting now runs off its own mongoDB collection. This once again introduces backwards incompatible schema changes, so a manual migration is required. You may upgrade from both v4.0 and v4.1 using the `[p]migrate blocklist` command. This removes any need to perform the previous migration steps in v4.1.0, you may upgrade directly to this version. After running the command, blocklist functionality will return and legacy config based blocks will have been deleted. You should always back up your config before migration. ### Deprecated - Legacy blocklist properties are deprecated and no longer function. They now log a warning when used and provide no functionality. They have been replaced with methods in blocklist.py +### Added +- Added `content_type` to attachments stored in the database. + ### Fixed - Persistent notes have been fixed after the previous discord.py update. +- `is_image` now is true only if the image is actually an image. # v4.1.0 diff --git a/core/clients.py b/core/clients.py index 91769da365..6ae313e5c2 100644 --- a/core/clients.py +++ b/core/clients.py @@ -666,9 +666,11 @@ async def append_log( { "id": a.id, "filename": a.filename, - "is_image": a.width is not None, + # In previous versions this was true for both videos and images + "is_image": a.content_type.startswith("image/"), "size": a.size, "url": a.url, + "content_type": a.content_type, } for a in message.attachments ],