|
|
|
|
@ -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"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|