[ADD] Starting DMs XMPP->Matrix

This commit is contained in:
LDA 2024-07-16 20:39:44 +02:00
commit 299f473a81
4 changed files with 108 additions and 5 deletions

View file

@ -431,6 +431,46 @@ ASCreateRoom(const ParseeConfig *conf, char *by, char *alias)
return id;
}
char *
ASCreateDM(const ParseeConfig *conf, char *by, char *with)
{
HttpClientContext *ctx = NULL;
HashMap *json = NULL;
char *path, *id;
if (!conf || !by || !with)
{
return NULL;
}
path = StrConcat(3,
"/_matrix/client/v3/createRoom",
"?user_id=", by
);
ctx = ParseeCreateRequest(
conf,
HTTP_POST, path
);
Free(path);
json = HashMapCreate();
{
Array *invitees = ArrayCreate();
ArrayAdd(invitees, JsonValueString(with));
HashMapSet(json, "invite", JsonValueArray(invitees));
HashMapSet(json, "is_direct", JsonValueBoolean(true));
}
ASAuthenticateRequest(conf, ctx);
ParseeSetRequestJSON(ctx, json);
JsonFree(json);
json = JsonDecode(HttpClientStream(ctx));
id = StrDuplicate(JsonValueAsString(HashMapGet(json, "room_id")));
HttpClientContextFree(ctx);
JsonFree(json);
return id;
}
void
ASSetAvatar(const ParseeConfig *conf, char *user, char *mxc)
{