[MOD] Import PNG media.

This commit is contained in:
LDA 2024-08-31 13:16:58 +02:00
commit 1f3d738bb4
12 changed files with 87 additions and 42 deletions

View file

@ -23,8 +23,8 @@ RouteHead(RouteMedia, arr, argp)
params = HttpRequestParams(args->ctx);
hmac = HashMapGet(params, "hmac");
/* TODO: Make it check the DB for its validicity. "Purging" would be useful.
*/
/* TODO: Make it check the DB for its validicity. "Purging" would be
* useful, alongside checking if someone isn't just a little idiotic. */
{
char *concat = StrConcat(3, server, "/", identi);
chkmak = ParseeHMACS(args->data->id, concat);
@ -32,12 +32,18 @@ RouteHead(RouteMedia, arr, argp)
}
if (!server || !identi || !hmac || !StrEquals(hmac, chkmak))
{
char *err =
hmac && StrEquals(hmac, chkmak) ?
"No server/identifier/HMAC code" :
"Hah! You _dirty_ little liar! Try a little harder!";
Free(chkmak);
HttpResponseStatus(args->ctx, HTTP_BAD_REQUEST);
return MatrixCreateError("M_NOT_YET_UPLOADED", "No server/identifier");
return MatrixCreateError("M_NOT_YET_UPLOADED", err);
}
Free(chkmak);
/* Proxy the media through an authenticated endpoint if the HMAC
* is valid. */
server = HttpUrlEncode(server);
identi = HttpUrlEncode(identi);
path = StrConcat(4, "/_matrix/media/v3/download/", server, "/", identi);