feat: use jpg for system notifications

This commit is contained in:
Zamitto
2025-11-12 08:17:53 -03:00
parent f84917a00b
commit c2216bbf95
5 changed files with 17 additions and 12 deletions

View File

@@ -153,8 +153,11 @@ def profile_image():
data = request.get_json()
image_path = data.get('image_path')
# use webp as default value for target_extension
target_extension = data.get('target_extension') or 'webp'
try:
processed_image_path, mime_type = ProfileImageProcessor.process_image(image_path)
processed_image_path, mime_type = ProfileImageProcessor.process_image(image_path, target_extension)
return jsonify({'imagePath': processed_image_path, 'mimeType': mime_type}), 200
except Exception as e:
return jsonify({"error": str(e)}), 400

View File

@@ -4,7 +4,7 @@ import os, uuid, tempfile
class ProfileImageProcessor:
@staticmethod
def get_parsed_image_data(image_path):
def get_parsed_image_data(image_path, target_extension):
Image.MAX_IMAGE_PIXELS = 933120000
image = Image.open(image_path)
@@ -16,7 +16,7 @@ class ProfileImageProcessor:
return image_path, mime_type
else:
new_uuid = str(uuid.uuid4())
new_image_path = os.path.join(tempfile.gettempdir(), new_uuid) + ".webp"
new_image_path = os.path.join(tempfile.gettempdir(), new_uuid) + "." + target_extension
image.save(new_image_path)
new_image = Image.open(new_image_path)
@@ -26,5 +26,5 @@ class ProfileImageProcessor:
@staticmethod
def process_image(image_path):
return ProfileImageProcessor.get_parsed_image_data(image_path)
def process_image(image_path, target_extension):
return ProfileImageProcessor.get_parsed_image_data(image_path, target_extension)

View File

@@ -5,15 +5,15 @@ const processProfileImageEvent = async (
_event: Electron.IpcMainInvokeEvent,
path: string
) => {
return processProfileImage(path);
return processProfileImage(path, "webp");
};
export const processProfileImage = async (path: string) => {
export const processProfileImage = async (path: string, extension?: string) => {
return PythonRPC.rpc
.post<{
imagePath: string;
mimeType: string;
}>("/profile-image", { image_path: path })
}>("/profile-image", { image_path: path, target_extension: extension })
.then((response) => response.data);
};

View File

@@ -18,7 +18,7 @@ import { getThemeSoundPath } from "@main/helpers";
import { processProfileImage } from "@main/events/profile/process-profile-image";
const getStaticImage = async (path: string) => {
return processProfileImage(path)
return processProfileImage(path, "jpg")
.then((response) => response.imagePath)
.catch(() => path);
};

View File

@@ -8,9 +8,11 @@ export const friendRequestEvent = async (payload: FriendRequest) => {
friendRequestCount: payload.friendRequestCount,
});
const user = await HydraApi.get(`/users/${payload.senderId}`);
if (payload.senderId) {
const user = await HydraApi.get(`/users/${payload.senderId}`);
if (user) {
publishNewFriendRequestNotification(user);
if (user) {
publishNewFriendRequestNotification(user);
}
}
};