[ADD] Be able to set the power level of an admin

Taking over users!
This commit is contained in:
LDA 2024-06-28 23:58:23 +02:00
commit 307fe6a341
3 changed files with 69 additions and 1 deletions

View file

@ -422,6 +422,50 @@ ASGetName(const ParseeConfig *c, char *room, char *user)
}
return ret;
}
HashMap *
ASGetPL(const ParseeConfig *c, char *room)
{
char *path;
HttpClientContext *ctx;
HashMap *reply;
if (!c || !room)
{
return NULL;
}
room = HttpUrlEncode(room);
path = StrConcat(4,
"/_matrix/client/v3/rooms/", room,
"/state/m.room.power_levels/", ""
);
ctx = ParseeCreateRequest(c, HTTP_GET, path);
Free(room);
ASAuthenticateRequest(c, ctx);
HttpRequestSendHeaders(ctx);
HttpRequestSend(ctx);
reply = JsonDecode(HttpClientStream(ctx));
HttpClientContextFree(ctx);
Free(path);
return reply;
}
void
ASSetPL(const ParseeConfig *conf, char *id, HashMap *m)
{
char *user;
if (!conf || !id || !m)
{
return;
}
user = StrConcat(4,
"@",conf->sender_localpart,
":",conf->homeserver_host
);
ASSetState(conf, id, "m.room.power_levels", "", user, m);
Free(user);
}
char *
ASUpload(const ParseeConfig *c, Stream *from, unsigned int size)
{