[FIX/WIP] Plumbing, -Werror, death to hitmen

Suspend killers are now no more. Except the actual killers to be gone
eventually.
Plumbing is also very basic as of now, but it "works".
This commit is contained in:
LDA 2024-07-05 20:24:15 +02:00
commit bb836789b2
23 changed files with 310 additions and 165 deletions

View file

@ -222,19 +222,33 @@ ASKick(const ParseeConfig *conf, char *id, char *banned)
HttpClientContextFree(ctx);
JsonFree(json);
}
void
char *
ASJoin(const ParseeConfig *conf, char *id, char *masquerade)
{
HttpClientContext *ctx = NULL;
HashMap *json = NULL;
char *path;
if (!conf || !id || !masquerade)
char *path, *ret;
if (!conf || !id)
{
return;
return NULL;
}
if (!masquerade)
{
char *raw = StrConcat(4,
"@", conf->sender_localpart,
":", conf->homeserver_host
);
masquerade = HttpUrlEncode(raw);
Free(raw);
}
else
{
masquerade = HttpUrlEncode(masquerade);
}
id = HttpUrlEncode(id);
path = StrConcat(5,
"/_matrix/client/v3/rooms/", id, "/join?",
"/_matrix/client/v3/join/", id, "?",
"user_id=", masquerade
);
@ -246,15 +260,23 @@ ASJoin(const ParseeConfig *conf, char *id, char *masquerade)
json = HashMapCreate();
ASAuthenticateRequest(conf, ctx);
ParseeSetRequestJSON(ctx, json);
JsonFree(json);
json = JsonDecode(HttpClientStream(ctx));
ret = StrDuplicate(GrabString(json, 1, "room_id"));
JsonFree(json);
HttpClientContextFree(ctx);
JsonFree(json);
Free(masquerade);
Free(id);
return ret;
}
void
ASSetState(const ParseeConfig *conf, char *id, char *type, char *key, char *mask, HashMap *state)
{
HttpClientContext *ctx = NULL;
char *path, *params;
char *path;
if (!conf || !id || !type || !mask || !state)
{
JsonFree(state);
@ -278,7 +300,7 @@ char *
ASSend(const ParseeConfig *conf, char *id, char *user, char *type, HashMap *c)
{
HttpClientContext *ctx = NULL;
char *path, *params;
char *path;
char *txn, *ret;
HashMap *reply;
if (!conf || !id || !type || !user || !c)
@ -626,7 +648,6 @@ ASReupload(const ParseeConfig *c, char *from, char **mime)
HttpClientContext *ctx;
unsigned short port;
int size = 0, flags = HTTP_FLAG_NONE;
int i;
char *ret, *content_len;
if (!c || !from)
@ -685,7 +706,7 @@ ASType(const ParseeConfig *c, char *user, char *room, bool status)
{
HttpClientContext *ctx = NULL;
HashMap *json;
char *path, *full;
char *path;
if (!c || !user || !room)
{
return;
@ -760,7 +781,6 @@ ASSetUserConfig(const ParseeConfig *c, char *user, char *key, HashMap *map)
{
HttpClientContext *ctx = NULL;
HashMap *json;
char *path;
if (!c || !key || !map)
{