[ADD] External URL for media events

This commit is contained in:
LDA 2024-07-07 18:27:37 +02:00
commit 517622a4ac

View file

@ -576,17 +576,26 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
char *mxc, *mime = NULL; char *mxc, *mime = NULL;
HashMap *content = NULL; HashMap *content = NULL;
oob_data = XMLookForUnique(oob, "url"); oob_data = XMLookForUnique(oob, "url");
oob_data = ArrayGet(oob_data->children, 0); oob_data =
oob_data ? ArrayGet(oob_data->children, 0) : NULL;
mxc = ASReupload(args->config, oob_data->data, &mime); if (oob_data)
content = MatrixCreateMedia(mxc, data->data, mime); {
mxc = ASReupload(args->config, oob_data->data, &mime);
content = MatrixCreateMedia(mxc, data->data, mime);
event_id = ASSend( /* Yeah, no, I'm not modifying the media creation code. */
args->config, mroom_id, encoded, HashMapSet(content, "external_url",
"m.room.message", content JsonValueString(oob_data->data)
); );
Free(mime);
Free(mxc); event_id = ASSend(
args->config, mroom_id, encoded,
"m.room.message", content
);
Free(mime);
Free(mxc);
}
} }
else if (reactions) else if (reactions)
{ {