Keep PM attachment kinds scoped to files voice and video

This commit is contained in:
evgeny committed 2026-10-01 17:43:53 +03:00
1 parent c7310e1fad
commit 984b9e8123
2 files changed
+3 -4

No files matched your search

+2 -3
View File
@@ -38,9 +38,9 @@ int attachment_validate(const struct attachment_info* info) {
if (wave) goto invalid;
if (info->kind == ATTACHMENT_FILE) {
if (info->duration_ms || info->width || info->height) goto invalid;
} else if (info->kind == ATTACHMENT_VIDEO || info->kind == ATTACHMENT_IMAGE) {
} else if (info->kind == ATTACHMENT_VIDEO) {
if (!info->width || !info->height || info->width > 16384 || info->height > 16384) goto invalid;
if (info->kind == ATTACHMENT_VIDEO ? (!info->duration_ms || info->duration_ms > 86400000) : info->duration_ms) goto invalid;
if (!info->duration_ms || info->duration_ms > 86400000) goto invalid;
} else goto invalid;
}
return 0;
@@ -81,7 +81,6 @@ const char* attachment_content_type(enum attachment_kind kind) {
switch (kind) {
case ATTACHMENT_VOICE: return "audio/opus";
case ATTACHMENT_VIDEO: return "video/mp4";
case ATTACHMENT_IMAGE: return "image/jpeg";
default: return "application/octet-stream";
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
extern "C" {
#endif
enum attachment_kind { ATTACHMENT_FILE = 1, ATTACHMENT_VOICE, ATTACHMENT_VIDEO, ATTACHMENT_IMAGE };
enum attachment_kind { ATTACHMENT_FILE = 1, ATTACHMENT_VOICE, ATTACHMENT_VIDEO };
#define ATTACHMENT_WAVE_SIZE 100
#define ATTACHMENT_WIRE_MAX (11 + 255 + ATTACHMENT_WAVE_SIZE)
struct attachment_info {