forked from Telodendria/Telodendria
[ADD/WIP] Try to parse a filter from raw JSON
Some checks are pending
Compile Telodendria / Compile Telodendria (x86, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, openbsd-v7.4) (push) Waiting to run
Some checks are pending
Compile Telodendria / Compile Telodendria (x86, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, openbsd-v7.4) (push) Waiting to run
This commit is contained in:
parent
3e5d9dbe62
commit
2b6805672b
3 changed files with 32 additions and 13 deletions
32
src/Filter.c
32
src/Filter.c
|
@ -29,6 +29,7 @@
|
|||
#include <Cytoplasm/Str.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Schema/Filter.h>
|
||||
|
||||
|
@ -204,6 +205,11 @@ FilterDecode(Db *db, char *user, char *filterStr, char **errp)
|
|||
Filter *ret;
|
||||
DbRef *filterRef;
|
||||
HashMap *filterObj;
|
||||
|
||||
FILE *fakeFile;
|
||||
Stream *fakeStream;
|
||||
|
||||
char *err;
|
||||
if (!db || !user || !filterStr)
|
||||
{
|
||||
if (errp)
|
||||
|
@ -216,8 +222,6 @@ FilterDecode(Db *db, char *user, char *filterStr, char **errp)
|
|||
|
||||
if (*filterStr != '{')
|
||||
{
|
||||
char *err;
|
||||
|
||||
filterRef = DbLock(db, 3, "filters", user, filterStr);
|
||||
filterObj = DbJson(filterRef);
|
||||
ret = Malloc(sizeof(*ret));
|
||||
|
@ -238,12 +242,28 @@ FilterDecode(Db *db, char *user, char *filterStr, char **errp)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* TODO: Decode JSON here... */
|
||||
if (errp)
|
||||
/* TODO: This should be it's own JSON function, in my
|
||||
* opinion. */
|
||||
fakeFile = fmemopen(filterStr, strlen(filterStr), "r");
|
||||
fakeStream = StreamFile(fakeFile);
|
||||
filterObj = JsonDecode(fakeStream);
|
||||
StreamClose(fakeStream); /* auto-frees fakeFile */
|
||||
ret = Malloc(sizeof(*ret));
|
||||
memset(ret, 0, sizeof(*ret));
|
||||
|
||||
if (!FilterFromJson(filterObj, ret, &err))
|
||||
{
|
||||
*errp = "Unimplemented feature: decoding from a raw JSON object";
|
||||
if (errp)
|
||||
{
|
||||
*errp = err;
|
||||
}
|
||||
JsonFree(filterObj);
|
||||
Free(ret);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
JsonFree(filterObj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -52,8 +52,8 @@ ROUTE_IMPL(RouteStaticLogin, path, argp)
|
|||
StreamPuts(stream,
|
||||
"function buildRequest(user, pass) {"
|
||||
" var d = findGetParameter('device_id');"
|
||||
" var i = findGetParameter('initial_device_display_name');"
|
||||
" var r = findGetParameter('refresh_token') === 'true';"
|
||||
" var i = findGetParameter('initial_device_display_name');"
|
||||
" var r = findGetParameter('refresh_token') === 'true';"
|
||||
" var request = {};"
|
||||
" request['type'] = 'm.login.password';"
|
||||
" request['identifier'] = {"
|
||||
|
@ -88,9 +88,9 @@ ROUTE_IMPL(RouteStaticLogin, path, argp)
|
|||
StreamPuts(stream,
|
||||
"onFormSubmit('login-form', (frm) => {"
|
||||
" var user = document.getElementById('user').value;"
|
||||
" var pass = document.getElementById('password').value;"
|
||||
" var pass = document.getElementById('password').value;"
|
||||
" if (!user || !pass) {"
|
||||
" setFormError('Please provide a username and password.');"
|
||||
" setFormError('Please provide a username and password.');"
|
||||
" return;"
|
||||
" }"
|
||||
" setFormError(null);"
|
||||
|
|
|
@ -1744,8 +1744,7 @@ UserAwaitNotification(char *user, int await)
|
|||
}
|
||||
else if (entry)
|
||||
{
|
||||
/* Another thread's awaiting...
|
||||
* TODO: Manage these conditions. */
|
||||
/* Another thread's awaiting... TODO: Manage these conditions. */
|
||||
Log(LOG_ERR,
|
||||
"Unimplemented feature: awaiting for other threads."
|
||||
);
|
||||
|
@ -1783,7 +1782,7 @@ UserAwaitNotification(char *user, int await)
|
|||
while (!entry->notified)
|
||||
{
|
||||
code = pthread_cond_timedwait(&entry->cond, &entry->lock, &timeout);
|
||||
if ((code == ETIMEDOUT))
|
||||
if (code == ETIMEDOUT)
|
||||
{
|
||||
timedout = true;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue