[ADD/WIP] Basic moderation

You now can ban people, yoohoo!
This commit is contained in:
LDA 2024-06-28 13:11:33 +02:00
commit 46489b50e6
5 changed files with 140 additions and 6 deletions

View file

@ -118,6 +118,41 @@ ASPing(const ParseeConfig *conf)
JsonFree(json);
}
void
ASBan(const ParseeConfig *conf, char *id, char *banned)
{
HttpClientContext *ctx = NULL;
HashMap *json = NULL;
char *path, *bridge;
if (!conf || !id || !banned)
{
return;
}
bridge = StrConcat(4,
"@", conf->sender_localpart,
":", conf->homeserver_host
);
path = StrConcat(5,
"/_matrix/client/v3/rooms/", id, "/ban",
"?user_id=", bridge
);
Free(bridge);
ctx = ParseeCreateRequest(
conf,
HTTP_POST, path
);
Free(path);
json = HashMapCreate();
HashMapSet(json, "user_id", JsonValueString(banned));
HashMapSet(json, "reason", JsonValueString("Parsee felt jealous."));
ASAuthenticateRequest(conf, ctx);
ParseeSetRequestJSON(ctx, json);
HttpClientContextFree(ctx);
JsonFree(json);
}
void
ASJoin(const ParseeConfig *conf, char *id, char *masquerade)
{
HttpClientContext *ctx = NULL;