[MOD] Actually redact

This commit is contained in:
LDA 2024-07-07 23:59:13 +02:00
commit 47823ba56b
3 changed files with 53 additions and 7 deletions

View file

@ -858,7 +858,6 @@ ASGetUserConfig(const ParseeConfig *c, char *user, char *key)
void
ASSetUserConfig(const ParseeConfig *c, char *user, char *key, HashMap *map)
{
HttpClientContext *ctx = NULL;
char *path;
if (!c || !key || !map)
@ -898,3 +897,52 @@ ASSetUserConfig(const ParseeConfig *c, char *user, char *key, HashMap *map)
return;
}
void
ASRedact(const ParseeConfig *c, char *room, char *user, char *e_id)
{
HttpClientContext *ctx = NULL;
HashMap *request;
char *path, *txn;
if (!c || !room || !e_id)
{
return;
}
if (!user)
{
char *raw = StrConcat(4,
"@", c->sender_localpart,
":", c->homeserver_host
);
user = HttpUrlEncode(raw);
Free(raw);
}
else
{
user = HttpUrlEncode(user);
}
room = HttpUrlEncode(room);
e_id = HttpUrlEncode(e_id);
txn = StrRandom(16);
path = StrConcat(9,
"/_matrix/client/v3/rooms/",
room, "/redact/", e_id, "/", txn,
"?", "user_id=", user
);
request = HashMapCreate();
ctx = ParseeCreateRequest(c, HTTP_PUT, path);
Free(path);
ASAuthenticateRequest(c, ctx);
ParseeSetRequestJSON(ctx, request);
JsonFree(request);
HttpClientContextFree(ctx);
Free(user);
Free(room);
Free(e_id);
Free(txn);
return;
}