mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:25:11 +00:00
[ADD] Starting DMs XMPP->Matrix
This commit is contained in:
parent
ed712a9f28
commit
299f473a81
4 changed files with 108 additions and 5 deletions
40
src/AS.c
40
src/AS.c
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue