[MOD] Add width/height information when possible

This commit is contained in:
LDA 2024-09-30 06:11:31 +02:00
commit d989331716
5 changed files with 103 additions and 3 deletions

View file

@ -79,7 +79,7 @@ MatrixCreateNickChange(char *nick)
return map;
}
HashMap *
MatrixCreateMedia(char *mxc, char *body, char *mime)
MatrixCreateMedia(char *mxc, char *body, char *mime, FileInfo *info)
{
HashMap *map;
char *mime_type = NULL, *matrix_type = NULL;
@ -120,6 +120,11 @@ MatrixCreateMedia(char *mxc, char *body, char *mime)
map = HashMapCreate();
JsonSet(map, JsonValueString(mime), 2, "info", "mimetype");
if (info && info->width && info->height)
{
JsonSet(map, JsonValueInteger(info->width), 2, "info", "w");
JsonSet(map, JsonValueInteger(info->height), 2, "info", "h");
}
HashMapSet(map, "msgtype", JsonValueString(matrix_type));
HashMapSet(map, "mimetype", JsonValueString(mime));
HashMapSet(map, "body", JsonValueString(body));