Compare commits

..

No commits in common. "main" and "task-416" have entirely different histories.

9 changed files with 56 additions and 384 deletions

View file

@ -1,130 +0,0 @@
/*
This file is part of »zeitbild«.
Copyright 2025 'kcf' <fenris@folksprak.org>
»zeitbild« is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
»zeitbild« is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
*/
namespace _zeitbild.api
{
/**
*/
export function register_user_get(
rest_subject : lib_plankton.rest_http.type_rest
) : void
{
register<
null,
{
name : string;
groups : Array<
int
>;
email_address : (
null
|
string
);
dav_token : (
null
|
string
);
settings : {
use_fallback_for_date_and_time_inputs : boolean;
weekview_vertical_default : boolean;
};
}
>(
rest_subject,
lib_plankton.http.enum_method.get,
"/user",
{
"description": "gibt die Angaben eines Nutzers aus",
"output_schema": () => ({
"nullable": false,
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"nullable": false,
"type": "number",
},
"name": {
"nullable": false,
"type": "string",
},
"groups": {
"nullable": false,
"type": "array",
"items": {
"nullable": false,
"type": "int",
}
},
"email_address": {
"nullable": true,
"type": "string",
},
"dav_token": {
"nullable": true,
"type": "string",
},
"settings": {
"nullable": false,
"type": "object",
"additionalProperties": false,
"properties": {
"use_fallback_for_date_and_time_inputs": {
"nullable": false,
"type": "boolean",
},
"weekview_vertical_default": {
"nullable": false,
"type": "boolean",
},
},
"required": [
"use_fallback_for_date_and_time_inputs",
"weekview_vertical_default",
],
},
},
"required": [
"id",
"name",
],
}),
"restriction": restriction_logged_in,
"execution": async (stuff) => {
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff);
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
const result : _zeitbild.type_user_object = await _zeitbild.service.user.get(user_id);
return Promise.resolve(
{
"status_code": 200,
"data": result,
}
);
}
}
);
}
}

View file

@ -58,7 +58,6 @@ namespace _zeitbild.api
// user // user
{ {
_zeitbild.api.register_users(rest_subject); _zeitbild.api.register_users(rest_subject);
_zeitbild.api.register_user_get(rest_subject);
// caldav // caldav
{ {
_zeitbild.api.register_user_dav_conf(rest_subject); _zeitbild.api.register_user_dav_conf(rest_subject);

View file

@ -324,10 +324,6 @@ namespace _zeitbild.auth
"groups": group_ids, "groups": group_ids,
"email_address": userinfo.email, "email_address": userinfo.email,
"dav_token": null, "dav_token": null,
"settings": {
"use_fallback_for_date_and_time_inputs": false,
"weekview_vertical_default": false,
}
}; };
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add( const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add(
user_object user_object

View file

@ -24,7 +24,7 @@ namespace _zeitbild.database
/** /**
*/ */
const _compatible_revisions : Array<string> = [ const _compatible_revisions : Array<string> = [
"r7", "r6",
]; ];

View file

@ -41,14 +41,6 @@ namespace _zeitbild.repository.calendar
}; };
/**
*/
type type_access_attributed_group_preview = {
group_id : int;
level : int;
};
/** /**
*/ */
type type_access_attributed_user_row = { type type_access_attributed_user_row = {
@ -58,14 +50,6 @@ namespace _zeitbild.repository.calendar
}; };
/**
*/
type type_access_attributed_user_preview = {
user_id : int;
level : int;
};
/** /**
*/ */
type type_dispersal = { type type_dispersal = {
@ -421,18 +405,16 @@ namespace _zeitbild.repository.calendar
const calendar_id : _zeitbild.type_calendar_id = await core_store.create( const calendar_id : _zeitbild.type_calendar_id = await core_store.create(
dispersal.core_row dispersal.core_row
); );
for await (const access_attributed_group_row of dispersal.access_attributed_group_rows) for await (const access_attributed_group_row of dispersal.access_attributed_group_rows) {
{
get_access_attributed_group_chest().write( get_access_attributed_group_chest().write(
[calendar_id, access_attributed_group_row.group_id], [calendar_id, access_attributed_group_row["group_id"]],
{"level": access_attributed_group_row.level} {"level": access_attributed_group_row["level"]}
); );
} }
for await (const access_attributed_user_row of dispersal.access_attributed_user_rows) for await (const access_attributed_user_row of dispersal.access_attributed_user_rows) {
{
get_access_attributed_user_chest().write( get_access_attributed_user_chest().write(
[calendar_id, access_attributed_user_row.user_id], [calendar_id, access_attributed_user_row["user_id"]],
{"level": access_attributed_user_row.level} {"level": access_attributed_user_row["level"]}
); );
} }
await lib_plankton.cache.clear(_zeitbild.cache_regular); await lib_plankton.cache.clear(_zeitbild.cache_regular);
@ -459,114 +441,82 @@ namespace _zeitbild.repository.calendar
// attributed:group // attributed:group
{ {
const access_attributed_group_chest = get_access_attributed_group_chest(); const access_attributed_group_chest = get_access_attributed_group_chest();
const hits : Array<{key : Array<any>; preview : type_access_attributed_group_row;}> = ( const hits : Array<Record<string, any>> = await access_attributed_group_chest.search(
(await access_attributed_group_chest.search(
{ {
"expression": "(calendar_id = $calendar_id)", "expression": "(calendar_id = $calendar_id)",
"arguments": { "arguments": {
"calendar_id": calendar_id, "calendar_id": calendar_id,
} }
} }
))
.map(
hit => (
{
"key": hit.key,
"preview": {
"group_id": hit.preview["group_id"],
"level": hit.preview["level"],
}
}
)
)
); );
const contrast = lib_plankton.list.contrast< const contrast = lib_plankton.list.contrast<
{key : Array<any>; preview : type_access_attributed_group_row;}, Record<string, any>,
type_access_attributed_group_row Record<string, any>
>( >(
hits, hits,
hit => hit.preview.group_id.toFixed(0), hit => hit["group_id"],
dispersal.access_attributed_group_rows, dispersal.access_attributed_group_rows,
row => row.group_id.toFixed(0) row => row["group_id"]
); );
// delete // delete
for await (const entry of contrast.only_left) for await (const entry of contrast.only_left) {
{
await access_attributed_group_chest.delete( await access_attributed_group_chest.delete(
[calendar_id, entry.left.preview.group_id] [calendar_id, entry.left["group_id"]]
); );
} }
// update // update
for await (const entry of contrast.both) for await (const entry of contrast.both) {
{
await access_attributed_group_chest.write( await access_attributed_group_chest.write(
[calendar_id, entry.right.group_id], [calendar_id, entry.right["group_id"]],
{"level": entry.right.level} {"level": entry.right["level"]}
); );
} }
// create // create
for await (const entry of contrast.only_right) for await (const entry of contrast.only_right) {
{
await access_attributed_group_chest.write( await access_attributed_group_chest.write(
[calendar_id, entry.right.group_id], [calendar_id, entry.right["group_id"]],
{"level": entry.right.level} {"level": entry.right["level"]}
); );
} }
} }
// attributed:user // attributed:user
{ {
const access_attributed_user_chest = get_access_attributed_user_chest(); const access_attributed_user_chest = get_access_attributed_user_chest();
const hits : Array<{key : Array<any>; preview : type_access_attributed_user_row;}> = ( const hits : Array<Record<string, any>> = await access_attributed_user_chest.search(
(await access_attributed_user_chest.search(
{ {
"expression": "(calendar_id = $calendar_id)", "expression": "(calendar_id = $calendar_id)",
"arguments": { "arguments": {
"calendar_id": calendar_id, "calendar_id": calendar_id,
} }
} }
))
.map(
hit => (
{
"key": hit.key,
"preview": {
"user_id": hit.preview["user_id"],
"level": hit.preview["level"],
}
}
)
)
); );
const contrast = lib_plankton.list.contrast< const contrast = lib_plankton.list.contrast<
{key : Array<any>; preview : type_access_attributed_user_row;}, Record<string, any>,
type_access_attributed_user_row Record<string, any>
>( >(
hits, hits,
hit => hit.preview.user_id.toFixed(0), hit => hit["user_id"],
dispersal.access_attributed_user_rows, dispersal.access_attributed_user_rows,
row => row.user_id.toFixed(0) row => row["user_id"]
); );
// delete // delete
for await (const entry of contrast.only_left) for await (const entry of contrast.only_left) {
{
await access_attributed_user_chest.delete( await access_attributed_user_chest.delete(
[calendar_id, entry.left.preview.user_id] [calendar_id, entry.left["user_id"]]
); );
} }
// update // update
for await (const entry of contrast.both) for await (const entry of contrast.both) {
{
await access_attributed_user_chest.write( await access_attributed_user_chest.write(
[calendar_id, entry.right.user_id], [calendar_id, entry.right["user_id"]],
{"level": entry.right.level} {"level": entry.right["level"]}
); );
} }
// create // create
for await (const entry of contrast.only_right) for await (const entry of contrast.only_right) {
{
await access_attributed_user_chest.write( await access_attributed_user_chest.write(
[calendar_id, entry.right.user_id], [calendar_id, entry.right["user_id"]],
{"level": entry.right.level} {"level": entry.right["level"]}
); );
} }
} }

View file

@ -45,23 +45,6 @@ namespace _zeitbild.repository.user
}; };
/**
*/
type type_settings_row_slim = {
use_fallback_for_date_and_time_inputs : int;
weekview_vertical_default : int;
};
/**
*/
type type_settings_row_fat = {
user_id : int;
use_fallback_for_date_and_time_inputs : int;
weekview_vertical_default : int;
};
/** /**
*/ */
type type_preview = { type type_preview = {
@ -74,7 +57,6 @@ namespace _zeitbild.repository.user
type type_dispersal = { type type_dispersal = {
core : type_core_row; core : type_core_row;
groups : Array<type_group_row_slim>; groups : Array<type_group_row_slim>;
settings : type_settings_row_slim;
}; };
@ -108,21 +90,6 @@ namespace _zeitbild.repository.user
) = null; ) = null;
/**
*/
var _store_settings : (
null
|
lib_plankton.storage.type_store<
int,
/*type_settings_row_fat*/Record<string, any>,
{},
lib_plankton.storage.type_sql_table_autokey_search_term,
Record<string, any>
>
) = null;
/** /**
*/ */
function get_store_core( function get_store_core(
@ -183,36 +150,6 @@ namespace _zeitbild.repository.user
} }
/**
*/
function get_store_settings(
)
: lib_plankton.storage.type_store<
int,
/*type_group_row_fat*/Record<string, any>,
{},
lib_plankton.storage.type_sql_table_autokey_search_term,
Record<string, any>
>
{
if (_store_settings === null)
{
_store_settings = lib_plankton.storage.sql_table_autokey_store(
{
"database_implementation": _zeitbild.database.get_implementation(),
"table_name": "user_settings",
"key_name": "id",
}
);
}
else
{
// do nothing
}
return _store_settings;
}
/** /**
*/ */
function encode( function encode(
@ -235,10 +172,6 @@ namespace _zeitbild.repository.user
) )
) )
), ),
"settings": {
"use_fallback_for_date_and_time_inputs": (user_object.settings.use_fallback_for_date_and_time_inputs ? 1 : 0),
"weekview_vertical_default": (user_object.settings.weekview_vertical_default ? 1 : 0),
},
}; };
} }
@ -259,10 +192,6 @@ namespace _zeitbild.repository.user
), ),
"email_address": dispersal.core.email_address, "email_address": dispersal.core.email_address,
"dav_token": dispersal.core.dav_token, "dav_token": dispersal.core.dav_token,
"settings": {
"use_fallback_for_date_and_time_inputs": (dispersal.settings.use_fallback_for_date_and_time_inputs > 0),
"weekview_vertical_default": (dispersal.settings.weekview_vertical_default > 0),
}
}; };
} }
@ -326,34 +255,6 @@ namespace _zeitbild.repository.user
) )
) )
); );
const settings_rows : Array<type_settings_row_slim> = (
(
await get_store_settings().search(
{
"expression": "(user_id = $user_id)",
"arguments": {
"user_id": user_id,
}
}
)
)
.map(
hit => (
{
// "user_id": hit.preview.user_id,
"use_fallback_for_date_and_time_inputs": hit.preview.use_fallback_for_date_and_time_inputs,
"weekview_vertical_default": hit.preview.weekview_vertical_default,
}
)
)
);
if (settings_rows.length !== 1)
{
return Promise.reject(new Error("no settings bound"));
}
else
{
const settings_row : type_settings_row_slim = settings_rows[0];
const dispersal : type_dispersal = { const dispersal : type_dispersal = {
"core": core_row, "core": core_row,
"groups": ( "groups": (
@ -364,13 +265,11 @@ namespace _zeitbild.repository.user
} }
) )
) )
), )
"settings": settings_row,
}; };
const user_object : _zeitbild.type_user_object = decode(dispersal); const user_object : _zeitbild.type_user_object = decode(dispersal);
return Promise.resolve<_zeitbild.type_user_object>(user_object); return Promise.resolve<_zeitbild.type_user_object>(user_object);
} }
}
/** /**
@ -396,15 +295,6 @@ namespace _zeitbild.repository.user
await get_store_groups().create(group_row_fat); await get_store_groups().create(group_row_fat);
} }
} }
// settings
{
const settings_row_fat : type_settings_row_fat = {
"user_id": user_id,
"use_fallback_for_date_and_time_inputs": dispersal.settings.use_fallback_for_date_and_time_inputs,
"weekview_vertical_default": dispersal.settings.weekview_vertical_default,
};
await get_store_settings().create(settings_row_fat);
}
return Promise.resolve<_zeitbild.type_user_id>(user_id); return Promise.resolve<_zeitbild.type_user_id>(user_id);
} }
@ -468,30 +358,6 @@ namespace _zeitbild.repository.user
} }
} }
} }
// settings
{
const settings_row_fat : type_settings_row_fat = {
"user_id": user_id,
"use_fallback_for_date_and_time_inputs": dispersal.settings.use_fallback_for_date_and_time_inputs,
"weekview_vertical_default": dispersal.settings.weekview_vertical_default,
};
const hits : Array<{key : int; preview : Record<string, any>;}> = await get_store_settings().search(
{
"expression": "(user_id = $user_id)",
"arguments": {
"user_id": user_id,
}
}
);
if (hits.length >= 1)
{
await get_store_settings().update(hits[0].key, settings_row_fat);
}
else
{
await get_store_settings().create(settings_row_fat);
}
}
return Promise.resolve<void>(undefined); return Promise.resolve<void>(undefined);
} }

View file

@ -276,10 +276,6 @@ namespace _zeitbild.sample
"groups": (user_raw.groups ?? []), "groups": (user_raw.groups ?? []),
"email_address": user_raw.email_address, "email_address": user_raw.email_address,
"dav_token": (user_raw.dav_token ?? null), "dav_token": (user_raw.dav_token ?? null),
"settings": {
"use_fallback_for_date_and_time_inputs": false,
"weekview_vertical_default": false,
},
}; };
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add( const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add(
user_object user_object

View file

@ -68,10 +68,6 @@ namespace _zeitbild
| |
string string
); );
settings : {
use_fallback_for_date_and_time_inputs : boolean;
weekview_vertical_default : boolean;
};
}; };

View file

@ -18,7 +18,7 @@ cmd_tsc := ${dir_tools}/typescript/node_modules/.bin/tsc
## rules ## rules
.PHONY: default .PHONY: default
default: node_modules ${dir_build}/zeitbild default: node_modules ${dir_build}/zeitbild node_modules
.PHONY: node_modules .PHONY: node_modules
node_modules: node_modules:
@ -62,7 +62,6 @@ ${dir_temp}/zeitbild-unlinked.js: \
${dir_source}/api/actions/session_status.ts \ ${dir_source}/api/actions/session_status.ts \
${dir_source}/api/actions/group_list.ts \ ${dir_source}/api/actions/group_list.ts \
${dir_source}/api/actions/users.ts \ ${dir_source}/api/actions/users.ts \
${dir_source}/api/actions/user_get.ts \
${dir_source}/api/actions/user_dav_conf.ts \ ${dir_source}/api/actions/user_dav_conf.ts \
${dir_source}/api/actions/user_dav_token.ts \ ${dir_source}/api/actions/user_dav_token.ts \
${dir_source}/api/actions/calendar_list.ts \ ${dir_source}/api/actions/calendar_list.ts \