mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 16:55:10 +00:00
[ADD/WIP] Bridge media Matrix->XMPP
We're on that Reverse Ideology phase.
This commit is contained in:
parent
82bed09b03
commit
fbf169a080
9 changed files with 118 additions and 6 deletions
49
src/Routes/Media.c
Normal file
49
src/Routes/Media.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include <Routes.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
|
||||
#include <Matrix.h>
|
||||
#include <Parsee.h>
|
||||
#include <AS.h>
|
||||
|
||||
RouteHead(RouteMedia, arr, argp)
|
||||
{
|
||||
ParseeHttpArg *args = argp;
|
||||
HttpClientContext *cctx;
|
||||
HashMap *reqh;
|
||||
char *server = ArrayGet(arr, 0);
|
||||
char *identi = ArrayGet(arr, 1);
|
||||
char *path, *key, *val;
|
||||
|
||||
/* TODO: Make it check the DB for its validicity. "Purging" would be useful.
|
||||
*/
|
||||
if (!server || !identi)
|
||||
{
|
||||
HttpResponseStatus(args->ctx, HTTP_BAD_REQUEST);
|
||||
return MatrixCreateError("M_NOT_YET_UPLOADED", "No server/identifier");
|
||||
}
|
||||
|
||||
server = HttpUrlEncode(server);
|
||||
identi = HttpUrlEncode(identi);
|
||||
path = StrConcat(4, "/_matrix/media/v3/download/", server, "/", identi);
|
||||
cctx = ParseeCreateRequest(args->data->config, HTTP_GET, path);
|
||||
ASAuthenticateRequest(args->data->config, cctx);
|
||||
Free(path);
|
||||
|
||||
HttpRequestSendHeaders(cctx);
|
||||
HttpRequestSend(cctx);
|
||||
reqh = HttpResponseHeaders(cctx);
|
||||
while (HashMapIterate(reqh, &key, (void **) &val))
|
||||
{
|
||||
HttpResponseHeader(args->ctx, key, val);
|
||||
}
|
||||
HttpSendHeaders(args->ctx);
|
||||
StreamCopy(HttpClientStream(cctx), HttpServerStream(args->ctx));
|
||||
|
||||
HttpClientContextFree(cctx);
|
||||
Free(server);
|
||||
Free(identi);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue