diff --git a/data/example.json b/data/example.json index ecad298..34d74c1 100644 --- a/data/example.json +++ b/data/example.json @@ -42,6 +42,7 @@ "events": [ { "name": "Aufstand: Mieten", + "public": false, "begin": { "timezone_shift": 2, "date": {"year": 2024, "month": 10, "day": 14}, @@ -57,6 +58,7 @@ }, { "name": "Aufstand: Waffen", + "public": false, "begin": { "timezone_shift": 2, "date": {"year": 2024, "month": 10, "day": 21}, @@ -72,6 +74,7 @@ }, { "name": "Aufstand: Essen", + "public": false, "begin": { "timezone_shift": 2, "date": {"year": 2024, "month": 11, "day": 28}, @@ -111,6 +114,7 @@ "events": [ { "name": "Feier: Bier", + "public": false, "begin": { "timezone_shift": 2, "date": {"year": 2024, "month": 10, "day": 18}, @@ -126,6 +130,7 @@ }, { "name": "Feier: Schnapps", + "public": false, "begin": { "timezone_shift": 2, "date": {"year": 2024, "month": 11, "day": 1}, @@ -161,6 +166,7 @@ "events": [ { "name": "Aufräumen: Flaschen", + "public": false, "begin": { "timezone_shift": 2, "date": {"year": 2024, "month": 10, "day": 24}, @@ -200,6 +206,7 @@ "events": [ { "name": "Infostand", + "public": false, "begin": { "timezone_shift": 2, "date": {"year": 2024, "month": 10, "day": 16}, diff --git a/source/database.ts b/source/database.ts index c88a3ab..020d70d 100644 --- a/source/database.ts +++ b/source/database.ts @@ -5,7 +5,7 @@ namespace _zeitbild.database /** */ const _compatible_revisions : Array = [ - "r1", + "r2", ]; diff --git a/source/main.ts b/source/main.ts index 83ffc25..4304b2b 100644 --- a/source/main.ts +++ b/source/main.ts @@ -97,7 +97,17 @@ async function data_init( /*const event_ids : Array<_zeitbild.type_local_resource_event_id> = */await Promise.all( calendar_raw.resource.data.events .map( - (event_raw : _zeitbild.type_event_object) => _zeitbild.service.resource.event_add(resource_id, event_raw) + (event_raw : _zeitbild.type_event_object) => _zeitbild.service.resource.event_add( + resource_id, + { + "name": event_raw["name"], + "public": (event_raw["public"] ?? false), + "begin": event_raw["begin"], + "end": (event_raw["end"] ?? null), + "location": (event_raw["location"] ?? null), + "description": (event_raw["description"] ?? null), + } + ) ) ); break; diff --git a/source/repositories/resource.ts b/source/repositories/resource.ts index ad68e7f..f8fd7c6 100644 --- a/source/repositories/resource.ts +++ b/source/repositories/resource.ts @@ -217,6 +217,7 @@ namespace _zeitbild.repository.resource return { "local_resource_id": stuff.local_resource_id, "name": stuff.event.name, + "public": stuff.event.public, "begin": encode_datetime(stuff.event.begin), "end": ( (stuff.event.end === null) @@ -271,6 +272,7 @@ namespace _zeitbild.repository.resource "local_resource_id": row["local_resource_id"], "event": { "name": row["name"], + "public": row["public"], "begin": decode_datetime(row["begin"]), "end": ( (row["end"] === null) diff --git a/source/repositories/sql/calendar_open.sql b/source/repositories/sql/calendar_open.sql new file mode 100644 index 0000000..8dfc13e --- /dev/null +++ b/source/repositories/sql/calendar_open.sql @@ -0,0 +1,44 @@ +SELECT + id AS id, + name AS name +FROM + calendars +WHERE + ( + resource_id + IN + ( + SELECT + id + FROM + resources + WHERE + ( + ( + (kind = 'local') + AND + ( + sub_id + IN + ( + SELECT + local_resource_id + FROM + local_resource_events + WHERE + (public = TRUE) + /* + GROUP BY + local_resource_id + */ + ) + ) + ) + OR + ( + (kind = 'caldav') + ) + ) + ) + ) +; diff --git a/source/services/calendar.ts b/source/services/calendar.ts index 3c6c63b..82a4951 100644 --- a/source/services/calendar.ts +++ b/source/services/calendar.ts @@ -342,6 +342,7 @@ namespace _zeitbild.service.calendar : "???" ), + "public": true, // todo? "begin": _zeitbild.helpers.ical_dt_to_own_datetime(vevent.dtstart), "end": ( (vevent.dtend !== undefined) diff --git a/source/types.ts b/source/types.ts index 920de23..fcc12e9 100644 --- a/source/types.ts +++ b/source/types.ts @@ -35,6 +35,7 @@ namespace _zeitbild */ export type type_event_object = { name : string; + public : boolean; begin : lib_plankton.pit.type_datetime; end : ( null