forked from Telodendria/Telodendria
[MOD] Revert single-property route
This commit is contained in:
parent
2233e5b7c6
commit
213f9fbb09
2 changed files with 4 additions and 24 deletions
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"header": "Schema\/AdminDeactivate.h",
|
||||
"types": {
|
||||
"DeactivateRequest": {
|
||||
"fields": {
|
||||
"reason": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "struct"
|
||||
}
|
||||
},
|
||||
"guard": "TELODENDRIA_SCHEMA_ADMINDEACTIVATE_H"
|
||||
}
|
|
@ -29,8 +29,6 @@
|
|||
|
||||
#include <User.h>
|
||||
|
||||
#include <Schema/AdminDeactivate.h>
|
||||
|
||||
ROUTE_IMPL(RouteAdminDeactivate, path, argp)
|
||||
{
|
||||
RouteArgs *args = argp;
|
||||
|
@ -39,7 +37,6 @@ ROUTE_IMPL(RouteAdminDeactivate, path, argp)
|
|||
|
||||
JsonValue *val;
|
||||
char *reason = "Deactivated by admin";
|
||||
char *err;
|
||||
char *removedLocalpart = ArrayGet(path, 0);
|
||||
char *token;
|
||||
|
||||
|
@ -50,8 +47,6 @@ ROUTE_IMPL(RouteAdminDeactivate, path, argp)
|
|||
|
||||
HttpRequestMethod method = HttpRequestMethodGet(args->context);
|
||||
|
||||
DeactivateRequest deactReq;
|
||||
|
||||
if ((method != HTTP_DELETE) && (method != HTTP_PUT))
|
||||
{
|
||||
char * msg = "Route only supports DELETE and PUT as for now.";
|
||||
|
@ -67,10 +62,10 @@ ROUTE_IMPL(RouteAdminDeactivate, path, argp)
|
|||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||
return MatrixErrorCreate(M_NOT_JSON, NULL);
|
||||
}
|
||||
if (!DeactivateRequestFromJson(request, &deactReq, &err))
|
||||
val = HashMapGet(request, "reason");
|
||||
if (val && JsonValueType(val) == JSON_STRING)
|
||||
{
|
||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||
return MatrixErrorCreate(M_BAD_JSON, err);
|
||||
reason = JsonValueAsString(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +99,7 @@ ROUTE_IMPL(RouteAdminDeactivate, path, argp)
|
|||
response = HashMapCreate();
|
||||
|
||||
JsonSet(response, JsonValueString(removedLocalpart), 1, "user");
|
||||
JsonSet(response, JsonValueString(deactReq.reason), 1, "reason");
|
||||
JsonSet(response, JsonValueString(reason), 1, "reason");
|
||||
JsonSet(response, JsonValueString(UserGetName(user)), 1, "banned_by");
|
||||
}
|
||||
else
|
||||
|
@ -116,7 +111,6 @@ ROUTE_IMPL(RouteAdminDeactivate, path, argp)
|
|||
finish:
|
||||
UserUnlock(user);
|
||||
UserUnlock(removed);
|
||||
DeactivateRequestFree(&deactReq);
|
||||
JsonFree(request);
|
||||
return response;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue