[MOD/ADD] Separate AS code, XMPP reactions removal

This commit is contained in:
LDA 2024-08-21 13:51:52 +02:00
commit fb511b4df0
16 changed files with 1183 additions and 1029 deletions

48
src/AS/Send.c Normal file
View file

@ -0,0 +1,48 @@
#include <AS.h>
#include <Cytoplasm/Memory.h>
#include <Cytoplasm/Str.h>
#include <Cytoplasm/Log.h>
#include <Cytoplasm/Uri.h>
#include <string.h>
#include <stdlib.h>
#include <Matrix.h>
char *
ASSend(const ParseeConfig *conf, char *id, char *user, char *type, HashMap *c)
{
HttpClientContext *ctx = NULL;
char *path;
char *txn, *ret;
HashMap *reply;
if (!conf || !id || !type || !user || !c)
{
JsonFree(c);
return NULL;
}
txn = StrRandom(16);
path = StrConcat(9,
"/_matrix/client/v3/rooms/",
id, "/send/", type, "/", txn, "?",
"user_id=", user
);
Free(txn);
ctx = ParseeCreateRequest(conf, HTTP_PUT, path);
Free(path);
ASAuthenticateRequest(conf, ctx);
ParseeSetRequestJSON(ctx, c);
reply = JsonDecode(HttpClientStream(ctx));
ret = StrDuplicate(JsonValueAsString(HashMapGet(reply, "event_id")));
JsonFree(reply);
HttpClientContextFree(ctx);
JsonFree(c);
return ret;
}