[AYA] See alsos, live-alongs, more documentation

I need to work on _actual_ Parsee, now
This commit is contained in:
LDA 2024-08-05 15:23:33 +02:00
commit aa71c5cfeb
10 changed files with 302 additions and 45 deletions

View file

@ -1,5 +1,11 @@
#ifndef PARSEE_AS_H
#define PARSEE_AS_H
/*-*
* Functions used to communicate with a Matrix server and execute actions
* over HTTP(S)+JSON. This effectively serves as Parsee's Matrix SDK.
* TODO: Write my own RanSDK for KappaChat.
* --------
* Writren-By: LDA */
#include <Cytoplasm/HttpClient.h>
#include <Cytoplasm/Json.h>
@ -7,9 +13,11 @@
#include <Parsee.h>
#include <Routes.h>
/* Verifies a request from the homeserver to match the
* hs_token. */
extern HashMap * ASVerifyRequest(ParseeHttpArg *);
/** Verifies a request from the homeserver to match the {hs_token}.
* ----------------
* Returns: A JSON error message[HEAP] | NULL on success
* Thrasher: JsonFree */
extern HashMap * ASVerifyRequest(ParseeHttpArg *arg);
/* Authenticates a request with the correct as_token.
* It does not send the request, however. */
@ -49,8 +57,19 @@ extern void ASRedact(const ParseeConfig *, char *room, char *user, char *e_id);
/* Sets a state event with a specific type and body */
extern void ASSetState(const ParseeConfig *conf, char *id, char *type, char *key, char *mask, HashMap *event);
/* Gets/Sets the content for a PL event */
/** Gets the content for a PL event in the room pointed by {id}
* ------------------------
* Returns: A valid JSON object[HEAP] | NULL
* Thrasher: JsonFree
* See-Also: ASSetPL */
extern HashMap *ASGetPL(const ParseeConfig *conf, char *id);
/** Sets the content for a PL event in the room pointed by {id} if
* possible.
* ------------------------
* Returns: NOTHING
* Modifies: the room pointed by {id}
* See-Also: ASGetPL */
extern void ASSetPL(const ParseeConfig *conf, char *id, HashMap *m);
/* Creates a room, with a masquerade user as its creator. This function
@ -62,14 +81,14 @@ extern char * ASCreateDM(const ParseeConfig *c, char *by, char *with);
/** Sets the user's global display{name}
* --------
* Returns: NOTHING
* Modifies: [EXT:User status]
* Modifies: the users' status in Matrix
* See-Also: ASGetName, ASSetStatus, ASSetAvatar */
extern void ASSetName(const ParseeConfig *c, char *user, char *name);
/** Sets the {user}'s global avatar, as an {mxc} URI
* --------
* Returns: NOTHING
* Modifies: [EXT:User status]
* Modifies: the users' status in Matrix
* See-Also: ASGetName, ASSetStatus */
extern void ASSetAvatar(const ParseeConfig *c, char *user, char *mxc);
@ -81,18 +100,32 @@ typedef enum UserStatus {
/** Sets the user's status and message, to be seen by other clients.
* --------
* Returns: NOTHING
* Modifies: [EXT:User status]
* Modifies: the users' status in Matrix
* See-Also: https://spec.matrix.org/v1.11/client-server-api/#put_matrixclientv3presenceuseridstatus, ASSetName, ASSetAvatar */
extern void ASSetStatus(const ParseeConfig *c, char *user, UserStatus status, char *msg);
/* Returns the user's name in a room, or a copy of the MXID itself, to be
* Free'd. */
/** Returns the user's name in a room, or a copy of the MXID itself, to be
* Free'd
* -------------
* Returns: The user's name in the room[HEAP] | A copy of {user}[HEAP]
* Thrasher: Free
* Modifies: NOTHING */
extern char * ASGetName(const ParseeConfig *c, char *room, char *user);
/* Uploads data to Matrix to be used later */
/** Uploads data to Matrix to be used later
* ----------------
* Returns: A valid MXC URI[HEAP] | NULL
* Thrasher: Free
* Modifies: the internal Matrix homeserver's media repository
* See-Also: ASReupload */
extern char * ASUpload(const ParseeConfig *c, Stream *from, unsigned int size, char *mime);
/* Reuploads a HTTP URL to Matrix, with an optional MIME type returned. */
/** Reuploads a HTTP URL to Matrix, with an optional MIME type returned.
* ----------------
* Returns: A valid MXC URI[HEAP] | NULL
* Thrasher: Free
* Modifies: the internal Matrix homeserver's media repository, {from}s server
* See-Also: ASUpload */
extern char * ASReupload(const ParseeConfig *c, char *from, char **mime);
extern HashMap * ASGetUserConfig(const ParseeConfig *c, char *user, char *key);