#include #include #include #include #include #include #include #include HashMap * ASFind(const ParseeConfig *c, char *room, char *event) { HttpClientContext *ctx = NULL; HashMap *json; char *path, *user; if (!c || !room || !event) { return NULL; } user = StrConcat(4, "@", c->sender_localpart, ":", c->server_base); path = StrConcat(7, "/_matrix/client/v3/rooms/", room, "/event/", event, "?", "user_id=", user ); ctx = ParseeCreateRequest(c, HTTP_GET, path); Free(path); ASAuthenticateRequest(c, ctx); HttpRequestSendHeaders(ctx); HttpRequestSend(ctx); json = JsonDecode(HttpClientStream(ctx)); HttpClientContextFree(ctx); Free(user); return json; } 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->server_base ); 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; }