forked from Telodendria/Telodendria
Fix bug in MatrixWellKnown(), begin /_matrix/client/v3/capabilities
This commit is contained in:
parent
2ac08ad74d
commit
098eed44a0
6 changed files with 63 additions and 4 deletions
|
@ -47,6 +47,10 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
|
|
||||||
requestPath = HttpRequestPath(context);
|
requestPath = HttpRequestPath(context);
|
||||||
|
|
||||||
|
Log(LOG_DEBUG, "%s %s",
|
||||||
|
HttpRequestMethodToString(HttpRequestMethodGet(context)),
|
||||||
|
requestPath);
|
||||||
|
|
||||||
HttpResponseStatus(context, HTTP_OK);
|
HttpResponseStatus(context, HTTP_OK);
|
||||||
HttpResponseHeader(context, "Server", "Telodendria/" TELODENDRIA_VERSION);
|
HttpResponseHeader(context, "Server", "Telodendria/" TELODENDRIA_VERSION);
|
||||||
|
|
||||||
|
@ -93,10 +97,8 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
HttpSendHeaders(context);
|
HttpSendHeaders(context);
|
||||||
|
|
||||||
stream = HttpServerStream(context);
|
stream = HttpServerStream(context);
|
||||||
|
|
||||||
JsonEncode(response, stream, JSON_DEFAULT);
|
JsonEncode(response, stream, JSON_DEFAULT);
|
||||||
JsonFree(response);
|
JsonFree(response);
|
||||||
|
|
||||||
StreamPrintf(stream, "\n");
|
StreamPrintf(stream, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +344,7 @@ MatrixClientWellKnown(char *base, char *identity)
|
||||||
HashMap *identityServer = HashMapCreate();
|
HashMap *identityServer = HashMapCreate();
|
||||||
|
|
||||||
HashMapSet(identityServer, "base_url", JsonValueString(identity));
|
HashMapSet(identityServer, "base_url", JsonValueString(identity));
|
||||||
HashMapSet(response, "m.identity_server", identityServer);
|
HashMapSet(response, "m.identity_server", JsonValueObject(identityServer));
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
|
@ -50,6 +50,7 @@ RouterBuild(void)
|
||||||
R("/_matrix/static/client/login", RouteStaticLogin);
|
R("/_matrix/static/client/login", RouteStaticLogin);
|
||||||
R("/_matrix/client/v3/auth/(.*)/fallback/web", RouteUiaFallback);
|
R("/_matrix/client/v3/auth/(.*)/fallback/web", RouteUiaFallback);
|
||||||
|
|
||||||
|
R("/_matrix/client/v3/capabilities", RouteCapabilities);
|
||||||
R("/_matrix/client/v3/login", RouteLogin);
|
R("/_matrix/client/v3/login", RouteLogin);
|
||||||
R("/_matrix/client/v3/logout", RouteLogout);
|
R("/_matrix/client/v3/logout", RouteLogout);
|
||||||
R("/_matrix/client/v3/logout/(all)", RouteLogout);
|
R("/_matrix/client/v3/logout/(all)", RouteLogout);
|
||||||
|
|
49
src/Routes/RouteCapabilities.c
Normal file
49
src/Routes/RouteCapabilities.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <Routes.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Memory.h>
|
||||||
|
#include <Json.h>
|
||||||
|
#include <HashMap.h>
|
||||||
|
#include <Str.h>
|
||||||
|
|
||||||
|
ROUTE_IMPL(RouteCapabilities, path, argp)
|
||||||
|
{
|
||||||
|
RouteArgs *args = argp;
|
||||||
|
HashMap *response;
|
||||||
|
HashMap *capabilities;
|
||||||
|
|
||||||
|
response = HashMapCreate();
|
||||||
|
capabilities = HashMapCreate();
|
||||||
|
|
||||||
|
JsonSet(capabilities, JsonValueBoolean(1), 2, "m.change_password", "enabled");
|
||||||
|
JsonSet(capabilities, JsonValueBoolean(1), 2, "m.set_displayname", "enabled");
|
||||||
|
JsonSet(capabilities, JsonValueBoolean(1), 2, "m.set_avatar_url", "enabled");
|
||||||
|
JsonSet(capabilities, JsonValueBoolean(0), 2, "m.3pid_changes", "enabled");
|
||||||
|
|
||||||
|
HashMapSet(response, "capabilities", JsonValueObject(capabilities));
|
||||||
|
return response;
|
||||||
|
}
|
|
@ -308,5 +308,6 @@ ROUTE_IMPL(RouteLogin, path, argp)
|
||||||
UserIdFree(userId);
|
UserIdFree(userId);
|
||||||
JsonFree(request);
|
JsonFree(request);
|
||||||
ConfigUnlock(config);
|
ConfigUnlock(config);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ HttpRouter *
|
||||||
ROUTE(RouteVersions);
|
ROUTE(RouteVersions);
|
||||||
ROUTE(RouteWellKnown);
|
ROUTE(RouteWellKnown);
|
||||||
|
|
||||||
|
ROUTE(RouteCapabilities);
|
||||||
ROUTE(RouteLogin);
|
ROUTE(RouteLogin);
|
||||||
ROUTE(RouteLogout);
|
ROUTE(RouteLogout);
|
||||||
ROUTE(RouteRegister);
|
ROUTE(RouteRegister);
|
||||||
|
|
|
@ -33,4 +33,9 @@ fi
|
||||||
|
|
||||||
export PATH="$(pwd)/tools/bin:$(pwd)/build/tools:$PATH"
|
export PATH="$(pwd)/tools/bin:$(pwd)/build/tools:$PATH"
|
||||||
export MANPATH="$(pwd)/man:$MANPATH"
|
export MANPATH="$(pwd)/man:$MANPATH"
|
||||||
export MALLOC_OPTIONS="CFGJS"
|
|
||||||
|
if [ "$(uname)" = "OpenBSD" ]; then
|
||||||
|
# Other platforms use different MALLOC_OPTIONS
|
||||||
|
# flags.
|
||||||
|
export MALLOC_OPTIONS="CFGJSU"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue