[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);

View file

@ -76,6 +76,7 @@ RouteHead(RouteRoot, arr, argp)
{
P("<title>%s Lander</title>", NAME);
P("<meta charset='UTF-8'/>");
P("<link rel='icon' href='data:image/png;base64,%s'/>", media_parsee_logo);
P("<style>");
{
P("html {");
@ -83,6 +84,15 @@ RouteHead(RouteRoot, arr, argp)
P("color: #eee;");
P("font-family: sans-serif;");
P("}");
P("#cols {");
P("column-count: 3;");
P("min-width: 100%;");
P("max-width: 100%;");
P("width: 100%;");
P("}");
P("img {");
P("image-rendering: pixelated;");
P("}");
P("blockquote {");
P("border-left: 2px solid #ccc;");
P("margin: 1.5em 10px;");
@ -105,9 +115,9 @@ RouteHead(RouteRoot, arr, argp)
P("<body>");
{
P("<center><h1>");
P("Your %s is running, all with that %s!", NAME, CODE);
P("</h1></center>");
P("<center>");
P("<h1>Your %s is running, all with that %s!</h1>", NAME, CODE);
P("</center>");
P("<hr/>");
P("<blockquote><i>");
{