[ADD/WIP] Do leaves right, PLwerk

This commit is contained in:
LDA 2024-07-07 01:21:51 +02:00
commit 4d055f3688
3 changed files with 114 additions and 9 deletions

View file

@ -273,6 +273,50 @@ ASJoin(const ParseeConfig *conf, char *id, char *masquerade)
return ret;
}
void
ASLeave(const ParseeConfig *conf, char *id, char *masquerade)
{
HttpClientContext *ctx = NULL;
HashMap *json = NULL;
char *path;
if (!conf || !id)
{
return;
}
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, "/leave?",
"user_id=", masquerade
);
ctx = ParseeCreateRequest(
conf,
HTTP_POST, path
);
Free(path);
json = HashMapCreate();
ASAuthenticateRequest(conf, ctx);
ParseeSetRequestJSON(ctx, json);
JsonFree(json);
HttpClientContextFree(ctx);
Free(masquerade);
Free(id);
}
void
ASSetState(const ParseeConfig *conf, char *id, char *type, char *key, char *mask, HashMap *state)
{
HttpClientContext *ctx = NULL;