Browse Source

Keep PM attachment kinds scoped to files voice and video

master
evgeny 2 days ago
parent
commit
984b9e8123
  1. 5
      src/media_async/attachment.c
  2. 2
      src/media_async/attachment.h

5
src/media_async/attachment.c

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

2
src/media_async/attachment.h

@ -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 {

Loading…
Cancel
Save