forked from Telodendria/Telodendria
Move client well-known generation to MatrixClientWellKnown() function.
We'll be using this for client login.
This commit is contained in:
parent
121682c006
commit
cc95c10f44
4 changed files with 34 additions and 21 deletions
4
TODO.txt
4
TODO.txt
|
@ -17,10 +17,10 @@ Milestone: v0.2.0
|
|||
[x] Move String functions to a new String.h
|
||||
[x] Make StringConcat use varargs
|
||||
[x] Look into seeding random strings (possibly create Random.h?)
|
||||
[~] User registration
|
||||
[x] User registration
|
||||
[x] Username validation
|
||||
[x] Password hashing
|
||||
[~] User API
|
||||
[x] User API
|
||||
|
||||
[x] Document MemoryHexDump()
|
||||
[x] Document DbExists()
|
||||
|
|
28
src/Matrix.c
28
src/Matrix.c
|
@ -358,3 +358,31 @@ MatrixRateLimit(HttpServerContext * context, Db * db)
|
|||
(void) db;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HashMap *
|
||||
MatrixClientWellKnown(char *base, char *identity)
|
||||
{
|
||||
HashMap *response;
|
||||
HashMap *homeserver;
|
||||
|
||||
if (!base)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
response = HashMapCreate();
|
||||
homeserver = HashMapCreate();
|
||||
|
||||
HashMapSet(homeserver, "base_url", JsonValueString(StrDuplicate(base)));
|
||||
HashMapSet(response, "m.homeserver", JsonValueObject(homeserver));
|
||||
|
||||
if (identity)
|
||||
{
|
||||
HashMap *identityServer = HashMapCreate();
|
||||
|
||||
HashMapSet(identityServer, "base_url", JsonValueString(StrDuplicate(identity)));
|
||||
HashMapSet(response, "m.identity_server", identityServer);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
ROUTE_IMPL(RouteWellKnown, args)
|
||||
{
|
||||
HashMap *response = NULL;
|
||||
char *pathPart = MATRIX_PATH_POP(args->path);
|
||||
|
||||
if (!MATRIX_PATH_EQUALS(pathPart, "matrix") || MATRIX_PATH_PARTS(args->path) != 1)
|
||||
|
@ -47,24 +46,9 @@ ROUTE_IMPL(RouteWellKnown, args)
|
|||
|
||||
if (MATRIX_PATH_EQUALS(pathPart, "client"))
|
||||
{
|
||||
HashMap *homeserver = HashMapCreate();
|
||||
|
||||
Free(pathPart);
|
||||
|
||||
response = HashMapCreate();
|
||||
|
||||
HashMapSet(homeserver, "base_url", JsonValueString(StrDuplicate(args->matrixArgs->config->baseUrl)));
|
||||
HashMapSet(response, "m.homeserver", JsonValueObject(homeserver));
|
||||
|
||||
if (args->matrixArgs->config->identityServer)
|
||||
{
|
||||
HashMap *identityServer = HashMapCreate();
|
||||
|
||||
HashMapSet(identityServer, "base_url", JsonValueString(StrDuplicate(args->matrixArgs->config->identityServer)));
|
||||
HashMapSet(response, "m.identity_server", identityServer);
|
||||
}
|
||||
|
||||
return response;
|
||||
return MatrixClientWellKnown(args->matrixArgs->config->baseUrl,
|
||||
args->matrixArgs->config->identityServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -86,6 +86,7 @@ extern HashMap *
|
|||
extern HashMap *
|
||||
MatrixRateLimit(HttpServerContext *, Db *);
|
||||
|
||||
|
||||
extern HashMap *
|
||||
MatrixClientWellKnown(char *, char *);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue