mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 16:45:10 +00:00
[ADD/WIP] Add some HTTP request code
We can now *register* users!
This commit is contained in:
parent
47c98cbbe3
commit
0fa95c2d14
12 changed files with 320 additions and 11 deletions
27
src/Main.c
27
src/Main.c
|
|
@ -4,6 +4,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <Parsee.h>
|
||||
#include <AS.h>
|
||||
|
||||
int
|
||||
Main(void)
|
||||
|
|
@ -12,12 +13,36 @@ Main(void)
|
|||
HttpServerConfig conf;
|
||||
ParseeData *data;
|
||||
const ParseeConfig *parseeConf;
|
||||
Stream *yaml;
|
||||
|
||||
Log(LOG_INFO, "%s - v%s", NAME, VERSION);
|
||||
ParseeConfigLoad("parsee.json");
|
||||
ParseeConfigInit();
|
||||
ParseeExportConfigYAML(StreamStdout());
|
||||
|
||||
yaml = StreamOpen("parsee.yaml", "w");
|
||||
ParseeExportConfigYAML(yaml);
|
||||
StreamClose(yaml);
|
||||
|
||||
parseeConf = ParseeConfigGet();
|
||||
Log(LOG_INFO, "HS token: %s", parseeConf->hs_token);
|
||||
|
||||
{
|
||||
/* Create user. We don't actually care about the value as we can
|
||||
* masquerade, as long as it exists. */
|
||||
HttpClientContext *ctx = ParseeCreateRequest(
|
||||
parseeConf,
|
||||
HTTP_POST, "/_matrix/client/v3/register"
|
||||
);
|
||||
HashMap *json = HashMapCreate();
|
||||
|
||||
HashMapSet(json,"type",JsonValueString("m.login.application_service"));
|
||||
HashMapSet(json,"username",JsonValueString(parseeConf->sender_localpart));
|
||||
|
||||
ASAuthenticateRequest(parseeConf, ctx);
|
||||
Log(LOG_INFO, "Got %d", ParseeSetRequestJSON(ctx, json));
|
||||
HttpClientContextFree(ctx);
|
||||
JsonFree(json);
|
||||
}
|
||||
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
conf.port = parseeConf->port;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue