mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 22:55:11 +00:00
[MOD/ADD] Separate AS code, XMPP reactions removal
This commit is contained in:
parent
1b62072a3a
commit
fb511b4df0
16 changed files with 1183 additions and 1029 deletions
48
src/AS/Send.c
Normal file
48
src/AS/Send.c
Normal 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;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue