[ADD/WIP] Matrix<->XMPP DMs.

There is still this fun issue with the blocking XML parser leaking
memory on pthread_cancel, I'll try to deal with that later, maybe with a
test stanza.

I also apologise for swearing in the last commit. I promise it won't
happen again, Prosody.
This commit is contained in:
LDA 2024-06-18 20:59:35 +02:00
commit 2cc4b0ed17
11 changed files with 325 additions and 63 deletions

View file

@ -13,21 +13,21 @@ extern HashMap * ASVerifyRequest(ParseeHttpArg *);
/* Authenticates a request with the correct as_token.
* It does not send the request, however. */
extern void ASAuthenticateRequest(ParseeConfig *, HttpClientContext *);
extern void ASAuthenticateRequest(const ParseeConfig *, HttpClientContext *);
/* Registers an user through the Application Service API. Returns
* true if the user was created. */
extern bool ASRegisterUser(ParseeConfig *, char *);
extern bool ASRegisterUser(const ParseeConfig *, char *);
/* Pings the homeserver to get attention. */
extern void ASPing(const ParseeConfig *);
/* Joins a room from an ID and a given user we want to masquerade
* as. */
extern void ASJoin(ParseeConfig *, char *, char *);
extern void ASJoin(const ParseeConfig *, char *, char *);
/* Sends a message event with a specific type and body.
* Said body is freed during the function's execution. */
extern void ASSend(ParseeConfig *, char *, char *, char *, HashMap *);
extern void ASSend(const ParseeConfig *, char *, char *, char *, HashMap *);
#endif

View file

@ -62,10 +62,7 @@ extern void ParseeConfigFree(void);
extern ParseeData * ParseeInitData(XMPPComponent *);
extern void ParseeFreeData(ParseeData *);
/* HTTP server handler for Parsee, takes in a config. */
extern void ParseeRequest(HttpServerContext *, void *);
extern HttpClientContext * ParseeCreateRequest(ParseeConfig *, HttpRequestMethod, char *);
extern HttpClientContext * ParseeCreateRequest(const ParseeConfig *, HttpRequestMethod, char *);
/* Sends headers, and writes the JSON object. */
extern HttpStatus ParseeSetRequestJSON(HttpClientContext *, HashMap *);
@ -79,9 +76,36 @@ extern bool ParseeIsPuppet(const ParseeConfig *, char *);
/* Decodes a local JID for a user into a string. */
extern char * ParseeDecodeLocalJID(const ParseeConfig *, char *);
/* Encodes a JID into a Parsee localpart */
extern char * ParseeEncodeJID(const ParseeConfig *, char *);
/* Gets the localpart of a MXID */
extern char * ParseeGetLocal(char *);
/* Encodes an MXID to a valid Jabber ID head */
extern char * ParseeEncodeMXID(char *);
/* Decodes a Jabber ID head into a valid MXID */
extern char * ParseeDecodeMXID(char *);
/* HTTP server handler for Parsee, takes in a config. */
extern void ParseeRequest(HttpServerContext *, void *);
/* A pthread callback used for listening to a component */
extern void * ParseeXMPPThread(void *data);
/* Finds the room a DM is associated to, from a Matrix user and a Jabber
* ID. */
extern char * ParseeFindDMRoom(ParseeData *data, char *mxid, char *jid);
/* Gets a DM ID from a Matrix and Jabber user */
extern char * ParseeGetDMID(char *mxid, char *jid);
/* Creates a DM mapping in the database */
extern void ParseePushDMRoom(ParseeData *, char *mxid, char *jid, char *r);
/* Trims the component from a JID */
extern char * ParseeTrimJID(char *jid);
#endif